Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

joseluisq/codeigniter3-hmvc-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codeigniter 3 HMVC Boilerplate

Boilerplate for creating Codeigniter 3 HMVC with Propel 2 ORM and OAuth2.

Features

  • CodeIgniter 3 with HMVC Modular Extension
  • Composer project
  • HTTP verbs: GET, POST, PUT and DELETE.
  • Propel 2 ORM (optional)
  • OAuth2 (optional)

Install

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

Propel 2

This project brings Propel 2 ORM buit-in.

Settings

Propel configuration file is located at /propel.yml.

Reverse Engineering

Reverse-engineer the XML schema based on given database.

$ ./propel database:reverse --output-dir=orm development

Build model classes

Build the model classes based on Propel XML schemas.

$ ./propel model:build

Build config file

Transform the configuration to PHP code leveraging the ServiceContainer.

$ ./propel config:conver

Build SQL

Build SQL files

$ ./propel sql:build

OAuth2

Client Credentials

POST http://localhost:8001/v1/login/oauth/access_token

Header params:

  • API-KEY : (View application/constants.php file for change API_KEY)
  • Authorization : client_id and client_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

API (example)

User API requires access_token.

Get all Users

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 specific User by Id

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.

License

MIT license

© 2016 José Luis Quintana