PHP code example of phauthentic / problem-details-symfony-bundle
1. Go to this page and download the library: Download phauthentic/problem-details-symfony-bundle 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/ */
phauthentic / problem-details-symfony-bundle example snippets
class ExampleController
{
public function __construct(
private ProblemDetailsFactoryInterface $problemDetailsFactory
) {
}
/**
* @Route("/example", methods={"POST"})
*/
public function exampleAction(Request $request): Response
{
return $this->problemDetailsFactory->createResponse(
type: 'https://example.net/validation-error',
detail: 'Your request is not valid.',
status: 422,
title: 'Validation Error',
);
}
}