PHP code example of alterway / rest-problem-bundle
1. Go to this page and download the library: Download alterway/rest-problem-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/ */
alterway / rest-problem-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Alterway\Bundle\RestProblemBundle\AwRestProblemBundle(),
);
}
use Alterway\Bundle\RestProblemBundle\Response\ProblemResponse;
use Alterway\Bundle\RestProblemBundle\Problem;
public function demoAction(Request $request)
{
$form = // (...)
$form->bind($request);
if (!$form->isValid()) {
$problem = new Problem\InvalidQueryForm($form);
return new ProblemResponse($problem, 403);
}
}
use Alterway\Bundle\RestProblemBundle\Response\ProblemResponse;
use Alterway\Bundle\RestProblemBundle\Controller\Annotations\Problem;
/**
* @Problem
*/
public function demoAction(Request $request)
{
$form = // (...)
$form->bind($request);
if (!$form->isValid()) {
return new Problem\InvalidQueryForm($form);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.