Download the PHP package yidas/codeigniter-rest without Composer

On this page you can find all versions of the php package yidas/codeigniter-rest. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package codeigniter-rest

CodeIgniter RESTful API


CodeIgniter 3 RESTful API Resource Base Controller

Latest Stable Version License

This RESTful API extension is collected into yidas/codeigniter-pack which is a complete solution for Codeigniter framework.

Features


OUTLINE


DEMONSTRATION

Output with status 200 OK:

RESTful Create Callback

Output with status 201 Created:

Packed Standard Format

Output with status 403 Forbidden:


REQUIREMENTS

This library requires the following:


INSTALLATION

Run Composer in your Codeigniter project under the folder \application:

composer require yidas/codeigniter-rest

Check Codeigniter application/config/config.php:

You could customize the vendor path into $config['composer_autoload']


CONFIGURATION

  1. Create a controller to extend yidas\rest\Controller,

  2. Add and implement action methods referring by Build Methods.

Then you could access RESTful API:

You could also use /ajax instead of /api if you like:

resource is Controller name, if you don't want to have /api or /ajax in URI you could set Routes Setting as below.

Routes Setting

If you want to have a standard RESTful URI pattern that controller defines as a URI resource, for example:

You could add a pair of routes for this controller into \application\config\routes.php to enable RESTful API url:


RESOURCE CONTROLLERS

The base RESTful API controller is yidas\rest\Controller, the following table is the actions handled by resource controller, the action refers to CI_Controller's action name which you could override:

HTTP Method URI (Routes Setting) Action Description
GET /photos index List the collection's members.
POST /photos store Create a new entry in the collection.
GET /photos/{photo} show Retrieve an addressed member of the collection.
PUT/PATCH /photos/{photo} update Update the addressed member of the collection.
PUT /photos update Update the entire collection.
DELETE /photos/{photo} delete Delete the addressed member of the collection.
DELETE /photos delete Delete the entire collection.

Without Routes Setting, the URI is like /photos/api & /photos/api/{photo}.

Build Methods:

You could make a resource controller by referring the Template of Resource Controller.

The following RESTful controller methods could be add by your need. which each method refers to the action of Resource Controller table by default, and injects required arguments:

$resourceID (string) is the addressed identity of the resource from request

$requestData (array) is the array input data parsed from request raw body, which supports data format of common content types. (Alternatively, use this->request->getRawBody() to get raw data)

Custom Routes & Methods

The default routes for mapping the same action methods of Resource Controller are below:

You could override it to define your own routes while creating a resource controller:

After reseting routes, each RESTful method (key) would enter into specified controller action (value). For above example, while access /resources/api/ url with GET method would enter into find() action. However, the default route would enter into index() action.

The keys refer to the actions of Resource Controller table, you must define all methods you need.

Behaviors

Resource Controller supports behaviors setting for each action, you could implement such as authentication for different permissions.

_setBehavior()

Set behavior to a action before route

Example:

Usage

pack()

Pack array data into body format

You could override this method for your application standard.

`

Example:

JSON Result:


HTTP REQUEST

The PSR-7 request component yidas\http\request is preloaded into yidas\rest\Controller, which provides input handler and HTTP Authentication. You could call it by $this->request in controller class.

Usage

getRawBody()

Returns the raw HTTP request body

Example:

getAuthCredentialsWithBasic()

Get Credentials with HTTP Basic Authentication

Example:

getAuthCredentialsWithBearer()

Get Credentials with OAuth 2.0 Authorization Framework: Bearer Token Usage

Example:


HTTP RESPONSE

The PSR-7 response component yidas\http\response is preloaded into yidas\rest\Controller, which provides output handler and formatter. You could call it by $this->response in controller class.

Usage

json()

JSON output shortcut

Example:

setFormat()

Set Response Format into CI_Output

Example:

setData()

Set Response Data into CI_Output

Example:

send()

Sends the response to the client.

Example:

withAddedHeader()

Return an instance with the specified header appended with the given value.

Example:


REFERENCE


All versions of codeigniter-rest with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yidas/codeigniter-rest contains the following files

Loading the files please wait ....