1. Go to this page and download the library: Download ttpryg/slim-api-starter 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/ */
use Symfony\Component\Validator\Constraints as Assert;
$validated = $validator->validate($data, [
'email' => [new Assert\NotBlank(), new Assert\Email()],
]);
use Symfony\Component\Validator\Constraints as Assert;
class UserDto
{
public function __construct(
#[Assert\NotBlank]
#[Assert\Email]
public string $email
) {}
}
$validator->validate($userDto);
public function __construct(private \Psr\Log\LoggerInterface $logger) {}
public function __invoke(...) {
$this->logger->info("This is a custom log entry");
}