PHP code example of jonjomckay / symfony-api-problem

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

    

jonjomckay / symfony-api-problem example snippets


use JonjoMcKay\ApiProblem\ApiProblem;
use JonjoMcKay\ApiProblem\ApiProblemResponse;

class FakeController
{

    public function fetch($id)
    {
        $entity = $this->service->fetch($id);

        if (!$entity) {
            return new ApiProblemResponse(new ApiProblem(404, 'Entity not found'));
        }

        return $entity;
    }
}