1. Go to this page and download the library: Download chonla/alex 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/ */
chonla / alex example snippets
$r = new Alex\Router();
$r->get('/', 'hello');
$r->get('/aa', 'hello 2');
$r->get('/bb', 'hello 3');
$r->get('/bb/:id', function($id) {
return new Alex\JsonResponse(200, [
'message' => 'It works! ID is '. print_r($id, true)
]);
});
$r->get('/cc/test', function() {
return new Alex\PassThroughResponse('http://www.google.com');
});
$r->post('/cc/test', function() {
return new Alex\JsonResponse(201, (new Alex\JsonRequest())->toJson());
});
$r->put('/cc/test', function() {
return new Alex\JsonResponse(200, (new Alex\JsonRequest())->toJson());
});
$r->delete('/cc/test', function() {
return new Alex\JsonResponse(200, [
'message' => 'It works! Item has gone'
]);
});
$r->go();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.