Installation
Installing Api Auto Pilot
To install Api Auto Pilot, you need to use Composer
composer require apiautopilot/apiautopilot
When Composer has finished downloading the package, you may execute the installation command using:
php artisan apiautopilot:install
Attempting to use the package without running the installation command first, will result in 404 HTTP Response Code
in all your models routes.
Post-Installation
API Routes File
When the installation of the package, is completed, you may notice that, in your routes/api.php
file 3 lines of code were added. if you had any previous API routes they are left as they were, nothing is changed. See more at: Configuring Routes
//routes/api.php
Route::prefix('/aap')->group(function () {
ApiAutoPilot\AutoPilotApi\Facades\AutoPilotApi::routes();
});
Http Kernel File
After the installation of the package a route middleware has been registered in the app/http/kernel.php
file, in the $routeMiddleware
array . That middleware is responsible for handling route resolves. Do not delete the middleware from the array, else the models' routes handled by Api Auto Pilot will result in a 404 Not Found HTTP Response
//app/Http/Kernel.php
protected $routeMiddleware = [
'modelSearch' => \ApiAutoPilot\AutoPilotApi\Http\Middleware\ModelSearch::class,
...
];
Configuration File
The installation command publishes the config file automatically. If for any reason you need to re-publish the configuration file again you can do so by using:
php artisan vendor:publish --tag=autopilot-api-config
The configuration file will look like this.
<?php
return [
'index' => [
'exclude' => [
],
],
'show' => [
'exclude' => [
],
],
'create' => [
'exclude' => [
],
],
'update' => [
'exclude' => [
],
],
'delete' => [
'exclude' => [
],
],
'attach' => [
'exclude' => [
],
],
'detach' => [
'exclude' => [
],
],
'sync' => [
'exclude' => [
],
],
'settings' => [
],
];