Boilerplate for creating CodeIgniter 3 HMVC with Propel 2 ORM and OAuth2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jose Quintana 7941437f98 revert previous commit 3 years ago
application Fix curl Exception params 3 years ago
orm RESTful, accept header and issue #2 fixed 3 years ago
sql OAuth2 support and RESTful improvements 3 years ago
test OAuth2 support and RESTful improvements 3 years ago
vendor Init 4 years ago
.gitignore Update .gitignore 4 years ago
.htaccess oauth2 improvements 3 years ago
composer.json revert previous commit 3 years ago
index.php Propel2 support 3 years ago
license.md Propel2 support 3 years ago
propel Propel2 support 3 years ago
propel.yml RESTful compatible, middleware and auth libs. 3 years ago
readme.md Accept header media type and minor fixes 3 years ago

readme.md

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