loadsys /
CakePHP-Stateless-Auth
A replacement CakePHP Authentication/Authorization Component that is fully and strictly stateless. Designed to be used with Cake apps that are only accessed RESTfully.
Loading repository data…
chriskacerguis / repository
A fully RESTful server implementation for CodeIgniter using one library, one config file and one controller.
A fully RESTful server implementation for CodeIgniter 3 using one library, one config file and one controller.
[!IMPORTANT] I have published the first "beta" of codeigniter-restserver 4. See the "development" branch. Please be sure to note the system requirments.
composer require chriskacerguis/codeigniter-restserver
CodeIgniter Rest Server is available on Packagist (using semantic versioning), and installation via composer is the recommended way to install Codeigniter Rest Server. Just add this line to your composer.json file:
"chriskacerguis/codeigniter-restserver": "^3.1"
or run
composer require chriskacerguis/codeigniter-restserver
Note that you will need to copy rest.php to your config directory (e.g. application/config)
Step 1: Add this to your controller (should be before any of your code)
use chriskacerguis\RestServer\RestController;
Step 2: Extend your controller
class Example extends RestController
Here is a basic example. This controller, which should be saved as Api.php, can be called in two ways:
http://domain/api/users/ will return the list of all usershttp://domain/api/users/id/1 will only return information about the user with id = 1<?php
defined('BASEPATH') OR exit('No direct script access allowed');
use chriskacerguis\RestServer\RestController;
class Api extends RestController {
function __construct()
{
// Construct the parent class
parent::__construct();
}
public function users_get()
{
// Users from a data store e.g. database
$users = [
['id' => 0, 'name' => 'John', 'email' => 'john@example.com'],
['id' => 1, 'name' => 'Jim', 'email' => 'jim@example.com'],
];
$id = $this->get( 'id' );
if ( $id === null )
{
// Check if the users data store contains users
if ( $users )
{
// Set the response and exit
$this->response( $users, 200 );
}
else
{
// Set the response and exit
$this->response( [
'status' => false,
'message' => 'No users were found'
], 404 );
}
}
else
{
if ( array_key_exists( $id, $users ) )
{
$this->response( $users[$id], 200 );
}
else
{
$this->response( [
'status' => false,
'message' => 'No such user found'
], 404 );
}
}
}
}
If you need to be able to support more formats for replies, you can extend the
Format class to add the required to_... methods
RestController class (in libraries/MY_REST_Controller.php)<?php
use chriskacerguis\RestServer\RestController;
class MY_REST_Controller extends RestController
{
public function __construct()
{
parent::__construct();
// This can be the library's chriskacerguis\RestServer\Format
// or your own custom overloaded Format class (see bellow)
$this->format = new Format();
}
}
Format class (can be created as a CodeIgniter library in libraries/Format.php).
Following is an example to add support for PDF output<?php
use chriskacerguis\RestServer\Format as RestServerFormat;
class Format extends RestServerFormat
{
public function to_pdf($data = null)
{
if ($data === null && func_num_args() === 0) {
$data = $this->_data;
}
if (is_array($data) || substr($data, 0, 4) != '%PDF') {
$html = $this->to_html($data);
// Use your PDF lib of choice. For example mpdf
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML($html);
return $mpdf->Output('', 'S');
}
return $data;
}
}
Selected from shared topics, language and repository description—not editorial ratings.
loadsys /
A replacement CakePHP Authentication/Authorization Component that is fully and strictly stateless. Designed to be used with Cake apps that are only accessed RESTfully.
A fully RESTful server implementation for CodeIgniter with basic authentication.
A Restful API for Marketplace system using many Type of relationships One to one many to many And fully supported JSON Format responses for a JSON format. Using PHP Fractal for transforming Responses and use laravel Policies and Gates to handle the user’s authorization Layer.
abdelrahim3aa /
E-commerce RESTful API: A secure, scalable API for managing e-commerce products and reviews, supporting CRUD operations and OAuth 2.0 authentication. Fully documented with OpenAPI 3.0, featuring robust error handling, data validation, and JSON-based data exchange for seamless front-end integration. with PHP and MySQL for a reliable and efficient BE
ZakaDev22 /
A fully functional Social Media Frontend Web Application built with Vanilla JavaScript, Bootstrap, and HTML/CSS. This project was developed as part of my advanced JavaScript training. It consumes a ready-made RESTful API built with PHP Laravel and MySQL, provided by Yarob Al Mostafa (instructor). The backend code is not included in this repository.
MohammadR3Z4 /
A fully functional CRUD system built on a RESTful API architecture