PHP code example of laravelista / syndra

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

    

laravelista / syndra example snippets


if ($e instanceof ValidationException) {
    return \Syndra::respondValidationError(
        $e->validator->errors()->getMessages()
    );
}

if ($e instanceof ModelNotFoundException) {
    return \Syndra::respondNotFound();
}

'providers' => [
    ...,
    Laravelista\Syndra\SyndraServiceProvider::class
];

'aliases' => [
    ...,
    'Syndra' => Laravelista\Syndra\Facades\Syndra::class
];

Syndra::respond(array $data)

Syndra::respondWithMessage($message='Ok')

Syndra::respondWithError($message='Error')

Syndra::respondOk($message='Ok')

Syndra::respondCreated($message='Created')

Syndra::respondUpdated($message='Updated')

Syndra::respondUnauthorized($message='Unauthorized')

Syndra::respondForbidden($message='Forbidden')

Syndra::respondNotFound($message='Not Found')

Syndra::respondValidationError($message='Validation Error')

Syndra::respondInternalError($message='Internal Error')

Syndra::respondNotImplemented($message='Not Implemented')

Syndra::setStatusCode($statusCode)

Syndra::setHeaders(array $headers)

return Syndra::setHeaders([
        'Access-Control-Allow-Origin' => '*',
    ])
    ->setStatusCode($statusCode)
    ->respond($data);

use Laravelista\Syndra\Syndra;

protected $syndra;

public function __construct(Syndra $syndra)
{
    $this->syndra = $syndra
}