PHP code example of phpdot / contracts

1. Go to this page and download the library: Download phpdot/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/ */

    

phpdot / contracts example snippets


use PHPdot\Contracts\Logs\WriterInterface;

final readonly class AuditService
{
    public function __construct(
        private WriterInterface $writer,
    ) {}
}

use PHPdot\Contracts\Logs\WriterInterface;

final class StdoutWriter implements WriterInterface
{
    public function write(array $record): void
    {
        fwrite(STDOUT, json_encode($record) . PHP_EOL);
    }
}