This is an updated five part series using PHP REST server with SLIM and Delphi VCL / FMX using both Indy Components and the newer REST components shipped with the Latest IDE. All processes use JSON to package the data to be sent and received.
If you are new to this, then you will be able to gain understanding on how it set up a REST App by following this 5 part series. More advanced processing using various Authorisations are implemented in the latter parts.
Lastly I have provided some background to REST, RESTAPI and JSON.
Feel free to read below a summary of each part or click on a link below to access one of the parts of the REST Series or scroll down to find out What REST is about?
Visit Part 1 - PHP PDO REST Server Part 1 - Slim Backend Webserver
Visit Part 2A - Delphi Basic CRUD REST Client– Indy Components with JSON
Visit Part 2B - Delphi REST VCL Client Basic Authorization and APIKey Authorization
Visit Part 3 - Delphi VCL REST Client Application using Indy and SuperObject.
Visit Part 4 - Delphi FMX REST Client Application using the latest REST Components
Visit Part 5 - PHP SLIM REST Server and Delphi VCL /Delphi FMX using 3 x Authorization methods.
Part 1 - PHP PDO REST Server Part 1 - Slim Backend Webserver. Visit the Blog
This covers the important steps to setup an effective PHP backend REST-Server using the lightweight Slim Rest Framework using Middleware with implemented routes. Whilst no Authorisation is implemented, the basic implementation steps are followed.
Part 2A- Delphi Basic CRUD REST Client– Indy Components with JSON-Visit the Blog
This uses Delphi VCL and the standard Indy Components shipped with the IDE. To implement JSON into the application, the excellent high quality Delphi SuperObject JSON library is used to send and receive RESTful calls to the Webserver and back. If you have an older IDE without the latest REST Components, then this Blog is for you to understand how to implement INDY and SuperObject.
Download the free to download REST Debugger from Embarcadero to test your REST Calls before implementation.
Part 2B - Delphi REST VCL Client Basic Auth Part 2B - Visit the blog
This is a follow on from Part 2A that demonstrated how you can add authorization to the code. Visit Part 2A.
Sending data across the internet is not secure by nature. The Rest Server will need to be secured and this depends on the nature of the data that is being stored. Here are two Authorization methods provided as snippets:-
Basic Authorization is the bare minimum however using APIKey Authorization ensures that the correct app is sending or receiving data. Yes you can combine both by forcing the Basic Authorization layer to authorize and once accepted then authorize the APIKey before transacting data. Visit the blog to find out more…
Part 3 – Delphi VCL REST Pricing Client App Part 3 – Visit Blog
This is a simple VCL Sales Price List that uses CRUD (create, read, update and delete) RESTful calls. The purpose of the app is to bio-directionally synchronise the base application and the Website’s Sales Price List.
This will demonstrate the basics of how to implement this and makes us of the Client Dataset
Component. To make it easier it simulates a database so the code should work out of the box.
It must be noted that this is a proof of concept and will need finer work before being production ready. If you are using a recent IDE then have a look at Part 4.
Part 4 - Delphi FMX REST Client App Part 4. Visit the Blog
This demonstrates a revision of the VCL Delphi Sales Price List Client Application upgraded to the latest IDE 10.2.3. Embarcadero has made enormous progress to provide powerful REST components and JSON Libraries with the ideal FIREDAC implementation.
Part 5 - PHP SLIM RESTServer &Delphi Auth. Visit the Blog
This is a two part blog which covers a lot of information. It deals in three authorization types :- Basic Authorization, APIKey Authorization and JWT Authorization methods.
This is a long blog and the first part covers the PHP RESTServer side.
The second part covers the RESTClient which is also split into Delphi VCL REST Client implementation and Delphi FMX REST Client implementation.
REST (Representational State Transfer) has become the standard design architecture for developing Web APIs.
REST is a stateless client-server relationship which means that unlike many other approaches there is no client context being stored server side.
No Sessions are required as each request contains all the information necessary for the server to authenticate the user and if authenticated then sends and receives data as per pre-determined calls to a set of HTTP URI endpoints.
REST takes advantage of the HTTP request methods to layer itself into the existing HTTP architecture.
These operations consist of the following:
GET - Used for basic read requests to the server.
PUT- Used to modify an existing object on the server.
POST- Used to create a new object on the server.
DELETE - Used to remove an object on the server.
By creating URI endpoints that utilize these operations, a RESTful API is quickly assembled.
In this sense the API stands for Application Programming Interface which allows for publicly exposed methods for an application to be accessed and manipulated outside of the program itself.
A common usage of an API is when you wish to obtain data from an application without having to actually visit the application Front end.
To allow this action to take place, the application will provide a published API that specifically allows for dissimilar applications to make calls to its data and return this data to the user from inside a Webserver. The REST API accesses the Database directly and will pass through specific information per each RESTful endpoint that is set up.
It is easily read as it is closer to text in nature verses XML and can be read on any text editor. Being lightweight, it is easy for machines to parse and generate and it is quick to transfer over slower internet connections.
Mobile phones are interfacing with the cloud regularly and band-width is a premium so the need for lightweight data such as JSON meets this requirement.
If you were new to RESTful processes and JSON, you now have a simplified understanding of what REST is all about. Select one of the five Part Series above to understand how to work with the RESTful components.
All code is under the MIT Licence and can be found in the Bayesean-Blog Github Repository and is easily downloadable at the end of each blog.
June 2019Delphi A Professional VCL DBGrid Part Four
May 2019Delphi A Professional VCL DBGrid Part Three
April 2019Delphi A Professional VCL DBGrid Part Two
March 2019Delphi A Professional VCL DBGrid Part One
November 2018Delphi VCL Buttons in DBGrid
October 2018Two Helper Apps for Delphi LibUSB
September 2018Delphi Libusb Library Introduction
August 2018Delphi Object directly to a Json string in a REST Client
July 2018Delphi FMX Leaflet Plotter using OSM Maps
June 2018C2PAS32 Convertor Application
May 2018Delphi PDF Embedded viewer with PDF.js
March 2018Delphi FMX - Changing TCharacter to TCharHelper
January 2018Delphi FMX Dashboard using Chart.JS
December 2017PHP Slim REST Server & Delphi Auth Part 5
November 2017Delphi FMX REST Client App Part 4
October 2017Delphi VCL REST Pricing Client App Part 3
September 2017Delphi REST VCL Client Basic Auth Part 2B
August 2017Delphi REST Client Part 2A
July 2017PHP REST Server and Delphi Client Intro
June 2017Delphi SQLite Encryptor-Decryptor Tool
May 2017Create a Visual IP Address Geolocation with PHP
March 2017PHP Downloader using Countdown timer
January 2017Morris Charts and PHP-PDO
December 2016CSS to create a functional Toggle Button