1. Go to this page and download the library: Download buzzingpixel/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/ */
buzzingpixel / container example snippets
$container = new \BuzzingPixel\Container\Container(
bindings: [
// You'd probably never do this exactly like this, but you get the idea
SomeClass::class => new SomeClass(),
// Bind a concrete implementation to an interface
SomeInterface::class => SomeImplementation::class,
// A factory method to create the requested class
AnotherClass::class => function (\Psr\Container\ContainerInterface $container): AnotherClass {
return new AnotherClass(
apiKey: env('API_KEY'),
someDependency: $container->get(SomeDependency::class),
);
}
],
);
$container = new \BuzzingPixel\Container\Container(
constructorParamConfigs: [
new \BuzzingPixel\Container\ConstructorParamConfig(
id: SomeClassToConfigure::class,
param: 'apiKey', // or whatever the name of the param is
give: 'fooBarApiKey',
),
new \BuzzingPixel\Container\ConstructorParamConfig(
id: AnotherClassToConfigure::class,
param: 'someInterface',
give: SomeConcreteImplementation::class,
),
],
);
$container = new \BuzzingPixel\Container\Container(
cacheAdapter: new \BuzzingPixel\Container\Cache\FileCache\FileCache(
cacheFileHandler: new \BuzzingPixel\Container\Cache\FileCache\CacheFileHandler(
cacheDirectoryPath: '/path/to/desired/cache/directory',
),
),
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.