1. Go to this page and download the library: Download nicollassilva/minasrouter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nicollassilva / minasrouter example snippets
MinasRouter\Router\Route;
// The second argument is optional. It separates the Controller and Method from the string
// Example: "Controller@method"
Route::start("http://yourdomain.com", "@");
Route::get("/", function() {
// ...
});
// ... all routes here
// You will put all your routes before this function
Route::execute();
Route::get('/users', [\App\Controllers\User::class, 'index']);
Route::post('/users', [\App\Controllers\User::class, 'store']);
Route::put('/users/{id}', [\App\Controllers\User::class, 'update']);
Route::patch('/users/{id}', [\App\Controllers\User::class, 'update']);
Route::delete('/users/{id}', [\App\Controllers\User::class, 'delete']);
// The router allows you to register routes that respond to any HTTP verb:
Route::any('/', function() {
// ...
});
// Sometimes you may need to register a route that responds to multiple HTTP verbs:
Route::match(["GET", "POST"], "/", function() {
// ...
});
Route::middleware(['auth', 'api'])->group(function() {
Route::get('/', function() {
// All middlewares will works in this route
});
Route::get('/no-api', function() {
// Only the auth middleware works here
})->withoutMiddleware('api');
});