Boilerplate for creating Codeigniter 3 HMVC with Propel 2 ORM and OAuth2.
- CodeIgniter 3 with HMVC Modular Extension
- Composer project
- HTTP verbs:
GET
,POST
,PUT
andDELETE
. - Propel 2 ORM (optional)
- OAuth2 (optional)
Clone this repository and install composer dependencies.
$ git clone https://github.com/joseluisq/codeigniter3-hmvc-boilerplate.git
$ cd codeigniter3-hmvc-boilerplate
$ composer install
Run development server.
$ php -S localhost:8001 -t path_project_directory
This project brings Propel 2 ORM buit-in.
Propel configuration file is located at /propel.yml
.
Reverse-engineer the XML schema based on given database.
$ ./propel database:reverse --output-dir=orm development
Build the model classes based on Propel XML schemas.
$ ./propel model:build
Transform the configuration to PHP code leveraging the ServiceContainer.
$ ./propel config:conver
Build SQL files
$ ./propel sql:build
POST http://localhost:8001/v1/login/oauth/access_token
Header params:
API-KEY
: (Viewapplication/constants.php
file for changeAPI_KEY
)Authorization
:client_id
andclient_secret
Example:
$ curl \
-H "API-KEY:32563b81ec7288ef87bbe39c3b7001a7bff35395eec1eac906a580e6a12d189e" \
-u admin \
-X POST http://localhost:8001/v1/login/oauth/access_token
Output:
{"access_token":"8ea0d5aedc6c7da8f3b6603b8ba783c85c7f0ef7","expires_in":3600,"token_type":"Bearer","scope":null}
Use Accept
header for choose the format of the data that you wish to receive.
For example: application/json
(default) and application/xml
User
API requires access_token
.
GET "http://localhost:8001/v1/user?access_token=..."
Example:
access_token
via query string:
$ curl \
-H "API-KEY: 32563b81ec7288ef87bbe39c3b7001a7bff35395eec1eac906a580e6a12d189e" \
-X GET "http://localhost:8001/v1/user?access_token=6b3a73aaa27f3a8495d7588fee56ab15628e64d7"
Or access_token
via Authentication
header:
$ curl \
-H "API-KEY: 32563b81ec7288ef87bbe39c3b7001a7bff35395eec1eac906a580e6a12d189e" \
-H "Authorization: Bearer 44cc7ead29d1855900c084d713ca21c9409a4675" \
-X GET "http://localhost:8001/v1/user"
GET "http://localhost:8001/v1/user/[:Id]?access_token=..."
Example:
$ curl \
-H "API-KEY: 32563b81ec7288ef87bbe39c3b7001a7bff35395eec1eac906a580e6a12d189e" \
-H "Authorization: Bearer 44cc7ead29d1855900c084d713ca21c9409a4675" \
-X GET "http://localhost:8001/v1/user/2"
Note: Check out application/config.php
for change default timezone.
MIT license
© 2016 José Luis Quintana