PHP code example of codingculture / request-resolver-bundle
1. Go to this page and download the library: Download codingculture/request-resolver-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/ */
codingculture / request-resolver-bundle example snippets
...
class SomeController extends Controller
{
public function someAction()
{
$request = $this->get('codingculture.requestresolver.resolver')->resolve(new SomeRequest());
$request->getId();
}
}
...
final class SomeRequest implements ResolvableRequestInterface
{
private $options = [];
public function getId(): string
{
return $this->options['id'];
}
public function defineOptions(OptionsResolver $resolver): OptionsResolver
{
$resolver->setRequired('id')
}
public function setOptions(array $options)
{
$this->options = $options;
}
public function getContentType(): string
{
return RequestResolver::CONTENT_TYPE_ALLOW_ALL;
}
}