1. Go to this page and download the library: Download passchn/cakephp-simple-di 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/ */
passchn / cakephp-simple-di example snippets
public function services(ContainerInterface $container): void
{
Configure::load('app_di');
$di = new DIManager([
ServiceFactoryManager::class => Configure::readOrFail('DI.services'),
]);
$di->addDependencies($container);
}
class ExamplesController {
public function someAction(NewsletterService $service): Response
{
$service->doSomething();
}
}
\SimpleDI\Module\ServiceLocator\ServiceLocator::getContainer(); // the container instance
\SimpleDI\Module\ServiceLocator\ServiceLocator::get(NewsletterService::class); // the service
// in your Application::services()
ServiceLocator::setContainer($container);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.