1. Go to this page and download the library: Download cspray/annotated-container 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/ */
cspray / annotated-container example snippets
declare(strict_types=1);
// interfaces and classes in __DIR__ . '/src'
use Cspray\AnnotatedContainer\Attribute\Service;
use Cspray\AnnotatedContainer\Attribute\InjectEnv;
#[Service]
interface BlobStorage {
public function store(string $identifier, string $contents) : void;
public function retrieve(string $identifier) : ?string;
}
#[Service]
class FilesystemStorage implements BlobStorage {
public function store(string $identifier, string $contents) : void {
file_put_contents($identifier, $contents);
}
public function retrieve(string $identifier) : ?string {
return file_get_contents($identifier) ?? null;
}
}
declare(strict_types=1);
// app bootstrap in __DIR__ . '/app.php'
tive profiles in this list
// If the only active profile is default you can call this method without any arguments
$profiles = ['default'];
$container = (new Bootstrap())->bootstrapContainer($profiles);
$storage = $container->get(BlobStorage::class); // instanceof FilesystemStorage
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.