1. Go to this page and download the library: Download flexi/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/ */
flexi / contracts example snippets
use Flexi\Contracts\Interfaces\HandlerInterface;
use Flexi\Contracts\Interfaces\DTOInterface;
use Flexi\Contracts\Interfaces\MessageInterface;
use Flexi\Contracts\Classes\PlainTextMessage;
class MyCommandHandler implements HandlerInterface
{
public function handle(DTOInterface $command): MessageInterface
{
// Your business logic here
return new PlainTextMessage('Command executed successfully');
}
}
use Flexi\Contracts\ValueObjects\ID;
use Flexi\Contracts\ValueObjects\Version;
$userId = new ID('user-123');
$appVersion = new Version(1, 5, 0);
echo $appVersion; // "1.5.0"
use Flexi\Contracts\Classes\EventListener;
use Flexi\Contracts\Interfaces\EventInterface;
class MyEventListener extends EventListener
{
public function handleEvent(EventInterface $event): void
{
// React to the event
$data = $event->getData();
// Process...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.