1. Go to this page and download the library: Download waffle-commons/contracts 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/ */
waffle-commons / contracts example snippets
namespace Waffle\Commons\Contracts\Core;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
interface KernelInterface
{
public function boot(): static;
public function configure(): void;
public function handle(ServerRequestInterface $request): ResponseInterface;
public function reset(): void;
}
namespace Waffle\Commons\Contracts\Config;
interface ConfigInterface
{
public function getInt(string $key, ?int $default = null): ?int;
public function getString(string $key, ?string $default = null): ?string;
public function getArray(string $key, ?array $default = null): ?array;
public function getBool(string $key, ?bool $default = null): ?bool;
}
namespace Waffle\Commons\Contracts\Attribute;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS)]
final readonly class Dto {}
use Waffle\Commons\Contracts\Attribute\Dto;
use Waffle\Commons\Contracts\Exception\Validation\ValidationExceptionInterface;
#[Dto]
final readonly class UserLoginDto
{
public string $email {
set(string $value) {
if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
throw new \DomainException('Invalid email');
}
$this->email = $value;
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.