aguilardc / moggie
Moggie PHP Micro Framework. A php micro framework recommended to create bare bones API applications
Requires
- php: >=8.1
- ext-pdo: *
- psr/http-message: ^2.0
- symfony/finder: ^6.2
- vlucas/phpdotenv: ^5.5
This package is auto-updated.
Last update: 2024-04-10 02:58:59 UTC
README
About
Moggie PHP is a lightweight, syntax elegant web micro-framework.
Requirements
Moggie PHP requires PHP 8.1 or greater.
Installation
1. Download the files.
If you're using Composer, you can run the following command:
composer require aguilardc/moggie
OR you can download them directly and extract them to your web directory.
Routing
Routing in Moggie PHP is done by matching a URL pattern with a callback function.
Route::get('/', function () { echo "Hello world!"; });
Named Parameters
You can specify named parameters in your routes which will be passed along to your callback function.
Route::get('/users/:name/:id', function($name, $id){ echo "hello, $name ($id)!"; });
Working with controllers
You can specify the name of a controller and the method to execute as a string.
the controller name must be separated from the action name with an @.
Route::get('/users', 'UsersController@read'); Route::get('/users/:id', 'UsersController@readById'); Route::post('/users', 'UsersController@create'); Route::put('/users/:id', 'UsersController@update'); Route::delete('/users/:id', 'UsersController@delete');
You can make use of static methods like GET, POST, PUT and DELETE
Note: The controller must be created in the /src/controllers directory and the called function must exist within it.
Security Vulnerabilities
If you discover a security vulnerability within Moggie PHP, please send an e-mail to Nevison Aguilar via aguilardc1105@gmail.com. All security vulnerabilities will be promptly addressed.
License
The Moggie PHP micro-framework is open-sourced software licensed under the MIT license.