php - Using container object from Included file
I got two index.php and both make use of a bootstrap.php. The bootstrap file is setting up a DI-Container and I need in both index files access to this DI-Container.
First I was thinking about using a simple
return in bootstrap.php:
<?php require __DIR__ . '/vendor/autoload.php'; $container = new League\Container\Container; // add some services return $container;
<?php $container = require __DIR__ . '/bootstrap.php'; $container->get('application')->run();
I read somewhere that using return statements like this are a bad habit. So I'm wondering how to make the container in the index.php accessible in an easy and proper way?