1. Go to this page and download the library: Download mrlijan/restmold 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/ */
mrlijan / restmold example snippets
protected function routes(): array
{
return [
'methodName' => [
'method' => 'GET', // The reuqest's method
'path' => '/index' // The reuqest's endpoint
],
];
}
use App\ApiModels\StudentsAPIModel;
class StudentsController extends BaseController
{
public function listByParams(StudentsAPIModel $students_api)
{
return $students_api->list([
'query' => [
'name' => 'Brendon',
'age' => '22'
]
]);
}
}
use App\ApiModels\StudentsAPIModel;
class StudentsController extends BaseController
{
public function createNewStudent(StudentsAPIModel $students_api)
{
return $students_api->create([
'body' => [
'firstName' => 'John',
'lastName' => 'Dow'
'age' => '24',
'email' => '[email protected]'
]
]);
}
}
protected function requestPipe(Request $request): Request
{
// ... manipulate the data, and return the request
return $request;
}
protected function responsePipe(Response $response): Response
{
// ... manipulate the data, and return the response
return $response;
}
php artisan restmold:generate <service name>
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.