Download the PHP package moudarir/codeigniter-rest-api without Composer
On this page you can find all versions of the php package moudarir/codeigniter-rest-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package codeigniter-rest-api
Codeigniter 3 API Rest
A RESTful server implementation for Codeigniter 3 based on CodeIgniter RestServer
Break changes made in version
3.0. Full code refactoring and new route system implemented inspired from Luthier CI.
Table of contents
- Requirements
- Installation
- Implementation
- Usage
- Postman collection
- Todo
Requirements
- PHP:
7.4to8.2tested. - Codeigniter:
^3.1.13. - Composer
Installation
The current version
3.0.*requires php 7.4 or higher (php supported versions)
This library uses Composer to be installed.
Run this command line (recommended) in the same path as your composer.json file:
Or, In your composer.json file, add the following code in require section:
And then run:
Implementation
Language / Translation
You can find the file associated with your language in the application/language/ folder. Based on the $config['language'] setting in your [your-project]/application/config/config.php configuration file.
Supported languages
- English
- French
- Arabic
Files & Configuration
The first thing to do is copying all required files in your CI project:
application/config/rest-api-server.php=>[your-project]/application/config/rest-api-server.phpapplication/controllers/DefaultController.php=>[your-project]/application/controllers/DefaultController.phpapplication/language/*/rest-api-server_lang.php=>[your-project]/application/language/*/rest-api-server_lang.phpapplication/routes/*=>[your-project]/application/routes/*
DO NOT change the
[your-project]/application/config/rest-api-server.phpand[your-project]/application/language/*/rest-api-server_lang.phpfilenames.
Make sure that the enable_hooks and composer_autoload keys in [your-project]/application/config/config.php file are set as following:
Next, set the following code in [your-project]/application/config/hooks.php file:
and in [your-project]/application/config/routes.php file:
Important
Execute the dumping/queries.sql file to create the tables needed for the API to work properly.
Tables that will be created are users, api_keys, api_key_limits and api_key_logs.
You're now ready to begin using the library 👌.
About Routes
The implementation of old routes is deprecated. The routes are now simplified for best use. See Usage.
Usage
Adding some routes for the next example in [your-project]/application/routes/api.php file (if not exists).
And now, we can create our [your-project]/application/controllers/api/ApiUsers.php controller:
Authentication methods
The Rest Server can be used with Basic or Bearer authorization type. However, it can be used without any authorization type (not secure).
The request limit currently only works in the Basic authorization type.
Postman collection
Import the collection
Downloaded our Postman collection, and import it into Postman.
Import the environment
We have also provided a Postman Environment that you need to import as well.
To understand what Postman environments are, please check this link.
Edit the environment variables
Update the endpoint variable to point to your Rest server. Ex: (https//myapi.com/) with trailing slash.
✨ That's it!
You can now use the Postman collection to test available requests.
In the Postman collection, the order of execution of the requests must be respected.
Todo
- Write routing HOW TO USE documentation.
- Improve documentation.
All versions of codeigniter-rest-api with dependencies
ext-json Version *
ext-libxml Version *
ext-simplexml Version *
firebase/php-jwt Version ^6.3
nesbot/carbon Version ^2.72