PHP code example of denysloshkarev / laravel-api

1. Go to this page and download the library: Download denysloshkarev/laravel-api 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/ */

    

denysloshkarev / laravel-api example snippets


protected static function getMethods(){
    return [
      'controllers' => [
        '{controllesKey1}' => [
            'controller' => '{Controller::class}',
            'actions' => [
                '{actionKey1}', // api/version/{controllesKey1}/{actionKey1}
                '{actionKey2}' => '{real method name}', //api/version/{controllesKey1}/{actionKey2}
                '{actionKey3}' => false, //disable //api/version/{controllesKey1}/{actionKey3}
                '{actionKey4}' => [
                    'exclude-all-middleware' => true, //optional, exclude all global and controller middleware
                    'middleware' => [
                        "{Middleware::class}"
                    ], //optional, define specific middleware 
                    'exclude-middleware' => [], //optional, exclude specific middleware
                ],
            ],
            'exclude-all-middleware' => true, //optional, ...
            'middleware' => [], //optional, ...
            'exclude-middleware' => [], //optional, ...
        ]
      ],
      'middleware' => [] //optional, ...
    ];
}


/**
 * Method title
 * Method description
 *
 * @input type $riable1 name1
 * @output type $variable2 name2
 */