PHP code example of ulrack / object-factory

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

    

ulrack / object-factory example snippets




use Ulrack\Storage\Component\ObjectStorage;
use Ulrack\ObjectFactory\Factory\ObjectFactory;
use Ulrack\ObjectFactory\Component\Analyser\ClassAnalyser;

$factory = new ObjectFactory(new ClassAnalyser(new ObjectStorage()))



use Ulrack\Storage\Component\ObjectStorage;

/** @var ObjectStorage $result */
$result = $factory->create(
    ObjectStorage::class,
    [
        'data' => ['foo']
    ]
);

$parameters = [
    'data' => [/** Value of $data here. */]
];



use Ulrack\Storage\Component\ObjectStorage;
use Ulrack\ObjectFactory\Factory\ObjectFactory;
use Ulrack\ObjectFactory\Component\Analyser\ClassAnalyser;

/** @var ObjectFactory $result */
$result = $factory->create(
    ObjectFactory::class,
    [
        'classAnalyser' => [
            'class' => ClassAnalyser::class,
            'parameters' => [
                'analysisStorage' => [
                    'class' => ObjectStorage::class,
                ],
            ],
        ],
    ]
);



use Ulrack\Storage\Component\ObjectStorage;
use Ulrack\ObjectFactory\Factory\ObjectFactory;
use Ulrack\ObjectFactory\Component\Analyser\ClassAnalyser;

$classAnalyser = new ClassAnalyser(new ObjectStorage());

/** @var ObjectFactory $result */
$result = $factory->create(
    ObjectFactory::class,
    [
        'classAnalyser' => $classAnalyser
    ]
);