PHP code example of ctors / pledge-symfony-routing
1. Go to this page and download the library: Download ctors/pledge-symfony-routing 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/ */
ctors / pledge-symfony-routing example snippets
#[Unveil('/', 'r')]
#[Unveil('/htdocs/var/log', 'rwc')]
#[Unveil('/htdocs/var/cache', 'rwc')]
class DnsLookupController extends AbstractController
{
#[Route('/hello', name: 'hello')]
#[Unveil] // Disallow future unveil calls
#[Pledge('stdio rpath wpath cpath fattr flock')]
public function index(): Response
{
return $this->render('hello/index.html.twig');
}
}
#[Unveil('/', 'r')]
#[Unveil('/htdocs/var/log', 'rwc')]
#[Unveil('/htdocs/var/cache', 'rwc')]
class DnsLookupController extends AbstractController
{
#[Route('/hello', name: 'hello')]
#[Unveil('/htdocs/src/Controller', 'rwc')]
#[Unveil] // Disallow future unveil calls
#[Pledge('stdio rpath wpath cpath fattr flock')]
public function index(): Response
{
file_put_contents(__DIR__.'/test', 'ohai');
return $this->render('hello/index.html.twig');
}
}
#[Unveil('/', 'r')]
#[Unveil('/htdocs/var/log', 'rwc')]
#[Unveil('/htdocs/var/cache', 'rwc')]
class DnsLookupController extends AbstractController
{
public function __construct(
private UserRepository $userRepository,
) {
}
#[Route('/hello', name: 'hello')]
#[Unveil] // Disallow future unveil calls
#[Pledge('stdio rpath wpath cpath fattr flock inet')]
public function index(): Response
{
return $this->render(
'hello/index.html.twig',
[
'users' => $this->userRepository->findAll(),
]
);
}
}