Wallogit.com
2017 © Pedro Peláez
A customizable Representational State Transfer (REST) Application Program Interface (API) designed to provide a quick set of tools for developers to quickly build their own API.
A customizable Representational State Transfer (REST) Application Program Interface (API) designed to provide a quick set of tools for developers to quickly build their own API., (*1)
Note: this repository is currently under construction., (*2)
REST-UP can be installed using composer:, (*3)
composer require maxcarter/restup
OR by simply extracting all files to the desired location in your website directory:, (*4)
git clone https://github.com/maxcarter/REST-UP.git rsync -r REST-UP/* Path/To/Destination
Once installed you should be able to see the welcome text at: http://YourDomain.com/PathToAPI, (*5)
Another way to test the API is to install the Chrome Extension Postman then open the app and send http requests to http://YourDomain.com/PathToAPI., (*6)
The sample code is based on the following MySQL table:, (*7)
CREATE TABLE `person` ( `id` int NOT NULL AUTO_INCREMENT, `Name` varchar(255) DEFAULT NULL, `City` varchar(255) DEFAULT NULL, `Email` varchar(255) DEFAULT NULL );
To insert sample data into this database:, (*8)
INSERT INTO `person` (`Name`, `City`, `Email`) VALUES
('Clark Kent', 'Smallville', 'superman@justiceleague.com');
To configure this REST-API to work with your database follow these steps:, (*9)
config.php with the appropriate credentials. models directory. (see models/person.php for a sample DTO) This REST API can be customized to work with different databases. The default preset is MySQL, however, you can create your own database controller to interface with different databases and implement custom functionality., (*10)
To create a custom controller follow these steps:, (*11)
/** * Create a new entry * @param [object] - The entry to be inserted * @return [object] - JSON result of insertion */ postValue($data); /** * Read all entries * @return [array] - An array of objects */ getValues(); /** * Read a single entry * @param [int] - The unique id of the entry * @return [object] - The requested entry */ getValue($value); /** * Update an entry * @param [object] - The entry to be updated * @return [object] - JSON result of update */ putValue($data); /** * Delete a single entry * @param [int] - The unique id of the entry * @return [object] - JSON result of deletion */ deleteValue($value);