PHP code example of eventhomes / laravel-apicontroller
1. Go to this page and download the library: Download eventhomes/laravel-apicontroller 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/ */
eventhomes / laravel-apicontroller example snippets
...
use EventHomes\Api\ApiController;
class MyController extends Controller {
use ApiController;
public function index() {
return $this->respond(['status' => 'hello world']);
}
}
//200 response
$this->respond();
//201 response
$this->respondCreated();
//500 error
$this->respondServerError();
//422 error
$this->respondUnprocessable();
//General error
$this->respondWithError('message here');