1. Go to this page and download the library: Download moxxie/moxrouter 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/ */
// Will only match GET HTTP requests
$router->get('/product/{id}', function($id){
// Return product with id = $id
});
// Will only match POST HTTP requests
$router->post('/product', function(){
// Create new a product
});
// Will only match PUT HTTP requests
$router->put('/product/{id}', function($id){
// Update product with id = $id
});
// Will only match PATCH HTTP requests
$router->patch('/product/{id}', function($id){
// Apply changes made to product with id = $id
});
// Will only match DELETE HTTP requests
$router->delete('/product/{id}', function($id){
// Delete product with id = $id
});
$router = new Moxxie\MoxRouter();
// Create an empty container
$container = [];
// Add a service to the container
$container['service'] = function(){
return new Service();
};
$router->get('/', function(){
// Use the new Service
$service = $this->service();
});
// Run the router with the container
$router->run($container);
$router->before(function(){
// This code will be executed before a route has been executed
});
$router->after(function(){
// This code will be executed after a route has been executed
});
$router->notFound(function(){
// This code will be executed when a route is not found
});
nginx
try_files $uri /index.php;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.