PHP code example of coloredcow / laravel-mobile-api

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

    

coloredcow / laravel-mobile-api example snippets


return $this->returnFormattedResponse(['projects' => $projects], 'project.index');

return $this->returnFormattedResponse(
    function () {
       // api response here
    },
    
    function () {
       // web response here
    }
);

public function render($request, Exception $exception)
{
    if($this->isApi()) {
        return $this->renderErrorResponseForAPI($exception);
    }
    return parent::render($request, $exception);
}
    

'restapi' => ColoredCow\LaravelMobileAPI\RestAPIMiddleware::class,

Route::group(['middleware' => ['auth:api', 'restapi:auth'] ], function () {
    // routes
});