Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ingeniasoftware/luthier-ci
Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework
https://github.com/ingeniasoftware/luthier-ci
codeigniter codeigniter-framework luthier-ci php router
Last synced: 8 days ago
JSON representation
Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework
- Host: GitHub
- URL: https://github.com/ingeniasoftware/luthier-ci
- Owner: ingeniasoftware
- License: mit
- Created: 2017-01-08T18:42:50.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2021-10-23T12:06:12.000Z (about 3 years ago)
- Last Synced: 2024-03-15T10:50:23.739Z (8 months ago)
- Topics: codeigniter, codeigniter-framework, luthier-ci, php, router
- Language: PHP
- Homepage: https://luthier.ingenia.me/ci/en/
- Size: 460 KB
- Stars: 149
- Watchers: 24
- Forks: 36
- Open Issues: 8
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- awesome-codeigniter - Luthier CI - Improved routing, middleware support, authentication tools and more for CodeIgniter 3 framework (Complex)
README
**Luthier CI** is an awesome set of core improvements for CodeIgniter 3 that makes the development of APIs (and websites in general) more easy!
## Features
* Easy installation via hooks
* Laravel-like routing: prefixes, namespaces, anonymous functions as routes, route groups, CLI routes, named parameters, optional parameters, etc.
* Middleware support
* Authentication library with SimpleAuth template
* PHP Debug Bar integration (experimental)## Requirements
* PHP >= 5.6.0 (PHP 7 compatible)
* CodeIgniter >= 3.0## Installation
#### Step 1: Get Luthier CI with Composer
```
composer require luthier/luthier
```#### Step 2: Enable Hooks and Composer autoload
```php
load->view('some_view');
});
```You can assign names to your routes so you don't have to worry about future url changes:
```php
Route::get('company/about_us', 'testcontroller@index')->name('about_us');
```To retrieve a named route, use the `route()` function:
If the route has parameters, pass a second argument to the function with an array of their values:
```php
= route('route_name', ['param1' => 'value2', 'param2' => 'value2' ... ]); ?>
```#### Route Groups
Group routes is possible with the `Route::group()` method. All routes
inside the group will share the *prefix* (first argument) and, optionally, another property (*namespace*, *middleware*, etc.)```php
// Prefix only
Route::group('prefix', function(){
Route::get('bar','test@bar');
Route::get('baz','test@baz');
});// Prefix and shared properties
Route::group('prefix', ['namespace' => 'foo', 'middleware' => ['Admin','IPFilter']], function(){
Route::get('bar','test@bar');
Route::get('baz','test@baz');
});
```## Middleware
All the middleware must be defined in the routes files (`application/routes/web.php`, `application/routes/api.php`, `application/routes/cli.php`)
```php
# Route middleware:
Route::put('foo/bar','controller@method', ['middleware' => ['Test']]);# Route group middleware:
Route::group('site', ['middleware' => ['Admin']], function(){
// ...
});# Global middleware:
Route::middleware('Admin', 'pre_controller');
```The middleware files must be saved in the `application/middleware` folder. If not exists, you must create it first. A middleware file is any php class that implements the `Luthier\MiddlewareInterface` interface and with a public `run()` method, which is the entry point. It's strongly advised to name all your middleware with CamelCase and avoid name conflicts with your controllers.
This is an example of a middleware:
```php