PHP code example of pine3ree / pine3ree-generic-factories
1. Go to this page and download the library: Download pine3ree/pine3ree-generic-factories 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/ */
pine3ree / pine3ree-generic-factories example snippets
use My\App\Model\PostMapper;
use Psr\Container\ContainerInterface;
use pine3ree\Container\Factory\ReflectionBasedFactory;
$container = the
// container
$postMapper = $factory($container, PostMapper::class);
use My\App\Model\Database\Db;
use My\App\Model\Database\PdoFactory;
use My\App\Model\PostMapper;
use PDO;
use Psr\Container\ContainerInterface;
use pine3ree\Container\Factory\ConfigurationBasedFactory;
$container = endencies' => [
'factories' => [
//...
PDO::class => PdoFactory::class, // Ad-hoc factory
//...
],
// Configuration key for dependencies built by the config-based factory
ConfigurationBasedFactory:class => [
// Just list the dependencies class names or container service-ids
// for each managed class
Db::class => [
PDO::class, // Resolved by a custom factory
],
PostMapper::class => [
Db::class, // Resolved by the config-based factory as well
'config', // THe 'config' array will be injected as 2nd argument
],
],
],
//...
];
$postMapper = $factory($container, PostMapper::class);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.