### Install PHP-DI with Composer Source: https://php-di.org/doc/getting-started Installs the PHP-DI library using Composer, the dependency manager for PHP. PHP-DI 7 requires PHP 8.0 or above. ```bash composer require php-di/php-di ``` -------------------------------- ### Create a PHP-DI Container Instance Source: https://php-di.org/doc/getting-started Demonstrates the basic creation of a PHP-DI container instance. For more advanced configuration, the ContainerBuilder is recommended. ```php $container = new DI\Container(); ``` -------------------------------- ### PHP Definitions Example Source: https://php-di.org/doc/getting-started An example of defining dependencies and services using PHP arrays, which PHP-DI can load. This method allows explicit configuration of service creation and injection, including using closures for custom factory logic. ```php return [ 'api.url' => 'http://api.example.com', 'Webservice' => function (Container $c) { return new Webservice($c->get('api.url')); }, 'Controller' => DI\create() ->constructor(DI\get('Webservice')), ]; ``` -------------------------------- ### Using PHP-DI ContainerBuilder Source: https://php-di.org/doc/getting-started Shows how to use the ContainerBuilder to create and configure a PHP-DI container instance, allowing for definition files and other options. ```php $builder = new DI\ContainerBuilder(); $builder->... $container = $builder->build(); ``` -------------------------------- ### PHP Classes Demonstrating Dependency Injection Source: https://php-di.org/doc/getting-started Example PHP classes showing how dependency injection is used, specifically a Mailer service and a UserManager that depends on it via its constructor. ```php class Mailer { public function mail($recipient, $content) { // send an email to the recipient } } ``` ```php class UserManager { private $mailer; public function __construct(Mailer $mailer) { $this->mailer = $mailer; } public function register($email, $password) { // The user just registered, we create his account // ... // We send him an email to say hello! $this->mailer->mail($email, 'Hello and welcome!'); } } ``` -------------------------------- ### Manual Dependency Wiring vs PHP-DI Source: https://php-di.org/doc/getting-started Demonstrates the difference between manually creating objects with their dependencies and letting PHP-DI handle it automatically via the container. This highlights the simplification provided by dependency injection containers. ```php $mailer = new Mailer(); $userManager = new UserManager($mailer); ``` ```php $userManager = $container->get('UserManager'); ``` -------------------------------- ### PHP-DI Configuration: Mapping Interfaces to Implementations Source: https://php-di.org/doc/best-practices Provides an example of mapping an interface to its concrete implementation in PHP-DI configuration. This is essential when type-hinting against interfaces to guide the container's autowiring process. ```php DIget(OrderService::class), ]; ``` -------------------------------- ### Basic Slim Route with PHP-DI Source: https://php-di.org/doc/frameworks/slim An example of defining a simple GET route in a Slim application that uses the PHP-DI bridge. It shows how to handle incoming requests and return a response, utilizing PSR-7 interfaces for request and response objects. ```php use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ResponseInterface as Response; // Assuming $app is already created using DI\Bridge\Slim\Bridge::create(); $app->get('/hello/{name}', function (Request $request, Response $response) { $name = $request->getAttribute('name'); $response->getBody()->write("Hello, {$name}!"); return $response; }); // Run the Slim application $app->run(); ``` -------------------------------- ### Environment-Specific Configuration Example Source: https://php-di.org/doc/environments Demonstrates how to define environment-specific parameters like database host and port, and then use them to configure a service (DbAdapter) within the PHP-DI container. ```php 'localhost', 'db.port' => 3336, 'DbAdapter' => DI\create() ->constructor(DI\get('db.host'), DI\get('db.port')), ]; ``` ```php '178.231.21.29', 'db.port' => 5000, ]; ``` ```php 'localhost', 'db.port' => 3336, ]; ``` ```php DI\create() ->constructor(DI\get('db.host'), DI\get('db.port')), ]; ``` -------------------------------- ### Install PHP-DI Slim Bridge Source: https://php-di.org/doc/frameworks/slim Installs the PHP-DI bridge for the Slim framework using Composer. This package enables PHP-DI's dependency injection features within a Slim application. It requires Composer to be installed and accessible. ```bash composer require php-di/slim-bridge ``` -------------------------------- ### Install Doctrine Cache for Caching Source: https://php-di.org/doc/migration/5.0 Provides the Composer command to install the doctrine/cache library, which is no longer a default dependency for PHP-DI. This is necessary if you intend to use caching. ```bash composer require doctrine/cache ``` -------------------------------- ### Configure Monolog Logger with PHP-DI Factory Source: https://php-di.org/doc/best-practices This example demonstrates how to configure a Monolog logger instance using PHP-DI's factory definition. It utilizes an anonymous function to encapsulate the complex setup, allowing for IDE support and real PHP code execution. The configuration uses the PSR-3 interface for the logger, enabling easy replacement with other compatible loggers. ```PHP DI\factory(function () { $logger = new Logger('mylog'); $fileHandler = new StreamHandler('path/to/your.log', Logger::DEBUG); $fileHandler->setFormatter(new LineFormatter()); $logger->pushHandler($fileHandler); return $logger; }), ]; ``` -------------------------------- ### Configure PhpStorm Metadata for PHP-DI Source: https://php-di.org/doc/ide-integration This snippet shows how to create a .phpstorm.meta.php file at the project root to enable PhpStorm's code completion for PHP-DI and PSR-11 containers. It uses the `override` and `map` functions to inform PhpStorm about the types returned by container `get` methods, improving autocompletion for injected services. ```PHP '@', ])); override("DI\Container::get", map([ '' => '@', ])); } ``` -------------------------------- ### Define Logger Service using ::class Source: https://php-di.org/doc/php-definitions Example of defining a service using the PHP 5.5 `::class` magic constant for type hinting and the `DI\create` helper function. ```PHP use Psr\Log\LoggerInterface; use Monolog\Logger; return [ LoggerInterface::class => DI\create(Logger::class) ]; ``` -------------------------------- ### Define Foo Service with Constructor Injection Source: https://php-di.org/doc/php-definitions Example of defining a service with constructor injection using PHP 5.6 function imports for `DI\create` and `DI\get`. ```PHP use function DI\create; use function DI\get; return [ 'Foo' => create() ->constructor(get('Bar')), ]; ``` -------------------------------- ### PHP-DI Lazy Proxy Instantiation Example Source: https://php-di.org/doc/lazy-injection Demonstrates how PHP-DI injects a proxy for a lazy object and how calling a method on the proxy triggers instantiation. The proxy is lightweight and behaves like the original object. ```php set('Foo', \DI\create()->lazy()); // $proxy is a Proxy object, it is not initialized // It is very lightweight in memory // $proxy = $container->get('Foo'); // var_dump($proxy instanceof Foo); // true // Calling a method on the proxy will initialize it // $proxy->doSomething(); // Now the proxy is initialized, the real instance of Foo has been created and called ``` -------------------------------- ### PHP-DI Autowiring Example Source: https://php-di.org/doc/definition-overriding Demonstrates basic autowiring in PHP-DI where a class constructor automatically receives an instance of its dependency. ```PHP class Foo { public function __construct(Bar $param1) { } } ``` -------------------------------- ### PHP-DI: Container Injection Example (After) Source: https://php-di.org/doc/scopes Shows how to inject the `DI\FactoryInterface` to explicitly use the container as a factory for creating objects, such as `Form` instances. ```php class Service { public function __construct(\DI\FactoryInterface $factory) { $this->form = $factory->make(Form::class, /* parameters */); } } ``` -------------------------------- ### PHP-DI: Prototype Scope Example (Before) Source: https://php-di.org/doc/scopes Illustrates the usage of `Scope::PROTOTYPE` in older versions of PHP-DI, where a new instance of a definition was created every time it was injected. ```php return [ Form::class => create() ->scope(Scope::PROTOTYPE) // a new form is created every time it is injected ]; class Service { public function __construct(Form $form) { $this->form = $form; } } ``` -------------------------------- ### PHP-DI: Factory Injection Example (After) Source: https://php-di.org/doc/scopes Demonstrates the recommended approach after scope removal, where a factory object is injected to create instances of `Form` on demand. ```php return [ FormFactory::class => create() ]; class Service { public function __construct(FormFactory $formFactory) { $this->form = $formFactory->createForm(); } } ``` -------------------------------- ### Get Entry from Container Source: https://php-di.org/doc/how-it-works Demonstrates the primary method for retrieving a registered entry from the PHP-DI container by its unique name. This is the main entry point for users interacting with the container. ```PHP $entry = $container->get('entryName'); ``` -------------------------------- ### PHP-DI Lazy Injection Example Source: https://php-di.org/doc/lazy-injection Demonstrates how PHP-DI's lazy injection defers the instantiation of dependencies like `PdfWriter` until they are actively used within the `ProductExporter` class. This is beneficial for performance when dependencies have costly constructors or many dependencies, preventing unnecessary initialization. ```PHP pdfWriter = $pdfWriter; $this->csvWriter = $csvWriter; } public function exportToPdf() { $this->pdfWriter->write(...); } public function exportToCsv() { $this->csvWriter->write(...); } } $productExporter = $container->get(ProductExporter::class); $productExporter->exportToCsv(); ``` -------------------------------- ### PHP-DI Autowiring Example Source: https://php-di.org/doc/autowiring Illustrates PHP-DI's autowiring capability where dependencies are automatically resolved and injected into a class constructor based on type declarations. PHP-DI uses reflection to determine the required parameters, creating instances if they don't exist. ```PHP class UserRepository { // ... } class UserRegistrationService { public function __construct(UserRepository $repository) { // ... } } // When PHP-DI needs to create UserRegistrationService, it automatically creates a UserRepository instance and passes it. // Equivalent to: // $repository = new UserRepository(); // $service = new UserRegistrationService($repository); ``` -------------------------------- ### PHP-DI Definition to Compiled Code Example Source: https://php-di.org/doc/performances Illustrates how PHP-DI transforms a definition for creating an object into equivalent compiled PHP code. This compiled code is then used at runtime for faster instantiation. ```php /* Definition */ return [ 'Logger' => DI\create() ->constructor('/tmp/app.log') ->method('setLevel', 'warning'), ]; /* Compiled Code Equivalent */ $object = new Logger('/tmp/app.log'); $object->setLevel('warning'); return $object; ``` -------------------------------- ### Nested Definitions and Factory Closures Source: https://php-di.org/doc/migration/6.0 Demonstrates how nested definitions and closures are handled in PHP-DI. Closures are now always interpreted as factory definitions, and the example shows how to use DI\value() for non-factory closures. ```php use function DI\env; use function DI\factory; use function DI\value; use function DI\create; return [ // Closures are always factories, even when nested in env() 'db.name' => env('DB_NAME', function ($container) { // Computes a default value if the environment variable doesn't exist return $container->get('db.prefix') . '_foo'; }), // Equivalent to the above using factory() explicitly 'db.name_explicit_factory' => env('DB_NAME', factory(function ($container) { return $container->get('db.prefix') . '_foo'; })), // Using DI\value() for closures not intended as factories 'router' => create(Router::class) ->method('setErrorHandler', value(function () { // This closure is treated as a value, not a factory ... })), ]; ``` -------------------------------- ### PHP-DI File Definition Override Example Source: https://php-di.org/doc/definition-overriding Illustrates overriding autowiring and attribute definitions using file-based definitions, allowing for more granular control over dependency injection. ```PHP return [ 'Foo' => DI::create() ->constructor(DI::get('another.specific.service')), // ... ]; ``` -------------------------------- ### PHP-DI Container Creation: buildDevContainer Removal Source: https://php-di.org/doc/migration/7.0 Illustrates the removal of the `DIContainerBuilder::buildDevContainer()` method in PHP-DI 7.0. The example shows the deprecated usage and its recommended replacement using the new `DIContainer()` constructor. ```php - $container = \DI\ContainerBuilder::buildDevContainer(); + $container = new \DI\Container(); ``` -------------------------------- ### PHP-DI: Simplified Dependency Management Source: https://php-di.org/doc/understanding-di Illustrates how PHP-DI automates the creation and injection of dependencies. Instead of manual instantiation, you retrieve services from the container and configure which concrete implementations to use. ```PHP $container->get('StoreService'); // Configuration example: $container->set('StoreService', \DI\create('GoogleMaps')); ``` -------------------------------- ### Configure Container with ContainerBuilder Source: https://php-di.org/doc/container-configuration Illustrates the basic usage of the ContainerBuilder class to create and configure the container. This is the recommended approach for more complex configurations. ```php $builder = new \DI\ContainerBuilder(); $container = $builder->build(); ``` -------------------------------- ### Instantiate Container Source: https://php-di.org/doc/container-configuration Demonstrates the simplest way to create a PHP-DI container instance. By default, autowiring is enabled and attributes are disabled. This provides a ready-to-use container with sensible defaults. ```php $container = new Container(); ``` -------------------------------- ### Install ZF2 Bridge Source: https://php-di.org/doc/frameworks/zf2 Installs the PHP-DI bridge for Zend Framework 2 using Composer. ```bash composer require php-di/zf2-bridge ``` -------------------------------- ### Classic Implementation Without DI Source: https://php-di.org/doc/understanding-di Demonstrates a traditional approach where classes directly instantiate their dependencies using `new` or singletons. This leads to tight coupling, making it difficult to swap implementations. ```PHP class GoogleMaps { public function getCoordinatesFromAddress($address) { // calls Google Maps webservice } } class StoreService { public function getStoreCoordinates($store) { $geolocationService = new GoogleMaps(); // or $geolocationService = GoogleMaps::getInstance() if you use singletons return $geolocationService->getCoordinatesFromAddress($store->getAddress()); } } ``` -------------------------------- ### Install PHP-DI Silex Bridge Source: https://php-di.org/doc/frameworks/silex This snippet shows the Composer command to install the PHP-DI Silex bridge, which enables integration between PHP-DI and the Silex micro-framework. ```bash $ composer require php-di/silex-bridge ``` -------------------------------- ### Install ZF1 Bridge Source: https://php-di.org/doc/frameworks/zf1 Installs the PHP-DI bridge for Zend Framework 1 using Composer. This package provides the necessary integration components. ```bash composer require php-di/zf1-bridge ``` -------------------------------- ### Initialize Container with Array Definitions Source: https://php-di.org/doc/php-definitions Demonstrates initializing a PHP-DI container by passing an array of definitions directly to the constructor. This is a straightforward method for setting up the container with configuration. ```PHP $container = new DI\Container([ // place your definitions here ]); ``` -------------------------------- ### PHP-DI: Creating New Instances with make() Source: https://php-di.org/doc/container Demonstrates how to use the `make()` method to create a new instance of a class, passing constructor arguments. `make()` resolves the entry every time it's called, creating new objects or executing factories, and allows overriding constructor parameters. ```PHP class GithubProfile { public function __construct(ApiClient $client, $user) ... } $container->make('GithubProfile', [ 'user' => 'torvalds', ]); ``` -------------------------------- ### PHP-DI Container Creation (PHP 7.0+) Source: https://php-di.org/doc/migration/7.0 Demonstrates the new, simplified way to create a PHP-DI container with default settings in version 7.0. It also shows how to provide definitions during instantiation. This replaces the older `ContainerBuilder` approach for default container creation. ```php $container = new \DI\Container(); // With definitions: $container = new \DI\Container([ \Psr\Log\LoggerInterface::class => get(MyLogger::class), ]); ``` -------------------------------- ### Install PHP-DI Symfony Bridge Source: https://php-di.org/doc/frameworks/symfony2 Installs the PHP-DI Symfony bridge package using Composer. This is the initial step required to enable PHP-DI integration within a Symfony application. ```Shell composer require php-di/symfony-bridge ``` -------------------------------- ### Install ProxyManager for Lazy Injection Source: https://php-di.org/doc/migration/5.0 Provides the Composer command to install the ProxyManager package, which is required for lazy injection in PHP-DI v5.0. Lazy injection is not enabled by default to reduce dependencies. ```bash composer require "ocramius/proxy-manager:~1.0" ``` -------------------------------- ### Basic Silex Application with PHP-DI Source: https://php-di.org/doc/frameworks/silex Demonstrates how to initialize a Silex application using `DI\Bridge\Silex\Application` and define a simple route. This replaces the standard `Silex\Application` to leverage PHP-DI's features. ```php get('/hello/{name}', function ($name) use ($app) { return 'Hello '.$app->escape($name); }); $app->run(); ``` -------------------------------- ### Building Container with Environment-Specific Definitions Source: https://php-di.org/doc/environments Shows how to use the ContainerBuilder to include a main configuration file and an environment-specific configuration file dynamically, allowing the latter to override or supplement the former. ```php $builder = new ContainerBuilder(); // Main configuration $builder->addDefinitions("config.php"); // Config file for the environment $builder->addDefinitions("config.$environment.php"); $container = $builder->build(); ``` -------------------------------- ### PHP-DI: PSR-11 Container Interface get() and has() Source: https://php-di.org/doc/container The PHP-DI container implements the PSR-11 standard, providing 'get()' and 'has()' methods. It is recommended to type-hint against the Psr\Container\ContainerInterface to ensure your code is decoupled from the specific container implementation. ```APIDOC namespace Psr\Container; interface ContainerInterface { /** * Finds an entry of the container. * * @param string $id * * @return mixed Entry. */ public function get($id); /** * Tests if an entry exists in the container. * * @param string $id * * @return bool */ public function has($id); } ``` -------------------------------- ### Standard Container Usage Source: https://php-di.org/doc/inject-on-instance Demonstrates the typical way to retrieve an object from the container, where all dependencies are automatically injected during instantiation. ```php $object = $container->get('foo'); ``` -------------------------------- ### Configure Container for Production Source: https://php-di.org/doc/container-configuration Explains how to configure the container for production environments to maximize performance. This involves enabling compilation and writing proxies to files for faster loading. ```php $builder = new \DI\ContainerBuilder(); $builder->enableCompilation(__DIR__ . '/tmp'); $builder->writeProxiesToFile(true, __DIR__ . '/tmp/proxies'); $container = $builder->build(); ``` -------------------------------- ### Configure Lightweight Container Source: https://php-di.org/doc/container-configuration Demonstrates how to create a lightweight container by explicitly disabling features like autowiring and attribute support. This can be useful for specific use cases where these features are not needed. ```php $builder = new \DI\ContainerBuilder(); $builder->useAutowiring(false); $builder->useAttributes(false); $container = $builder->build(); ``` -------------------------------- ### Inject Dependency in Controller Source: https://php-di.org/doc/frameworks/zf2 Example of injecting a service dependency into a Zend Framework 2 controller using PHP-DI attributes for automatic injection. ```php class GuestbookController extends AbstractActionController { /** * This dependency will be injected by PHP-DI */ #[Inject] private \Application\Service\GuestbookService $guestbookService; public function indexAction() { $this->view->entries = $this->guestbookService->getAllEntries(); } } ``` -------------------------------- ### PHP-DI Attribute Override Example Source: https://php-di.org/doc/definition-overriding Shows how to use PHP attributes to override autowiring for a constructor parameter, specifying a particular service name. ```PHP use DI\Attribute\Inject; class Foo { #[Inject(['my.specific.service'])] public function __construct(Bar $param1) { } } ``` -------------------------------- ### PHP-DI: Basic Object Creation with DI\create() Source: https://php-di.org/doc/php-definitions Demonstrates the basic usage of DI\create() to instantiate classes, map interfaces to implementations, and assign arbitrary entry names. It shows how to create objects directly or by specifying an implementation class. ```php return [ // instantiate the Logger class to create the object 'Logger' => DI\create(), // mapping an interface to an implementation 'LoggerInterface' => DI\create('MyLogger'), // using an arbitrary name for the entry 'logger.for.backend' => DI\create('Logger'), ]; ``` -------------------------------- ### Add Definitions from Configuration File Source: https://php-di.org/doc/php-definitions Demonstrates loading container definitions from an external PHP file using the container builder. This is a common practice for managing complex configurations. ```PHP $containerBuilder->addDefinitions('config.php'); ``` -------------------------------- ### PHP Constructor Injection and Autowiring for Services Source: https://php-di.org/doc/best-practices Illustrates recommended constructor injection for services, leveraging PHP-DI's autowiring feature. This method promotes explicit dependencies and testability for reusable components. ```php class OrderService implements OrderServiceInterface { private $paymentService; public function __construct(PaymentServiceInterface $paymentService) { $this->paymentService = $paymentService; } public function processOrder($order) { $this->paymentService->... } } ``` -------------------------------- ### DI\link() Replacement Guidance Source: https://php-di.org/doc/migration/6.0 Explains that the DI\link() helper function has been removed and should be replaced with DI\get(). This change simplifies dependency linking within the container configuration. ```php // DI\link() is removed, use DI\get() instead. // Example: // 'myService' => DI\get('AnotherService::class') ``` -------------------------------- ### Injecting Dependencies on Existing Instance Source: https://php-di.org/doc/inject-on-instance Shows how to use the `injectOn` method to inject dependencies into an object that has already been created, typically by external means. ```php // $object is an instance of some class $container->injectOn($object); ``` -------------------------------- ### PHP-DI Nesting Definitions with Constructor Source: https://php-di.org/doc/php-definitions Illustrates how to nest definitions within other definitions in PHP-DI to avoid polluting the container. This example shows nesting a `DI\create()` call with constructor arguments, including other nested definitions. ```php return [ 'Foo' => DI\create() ->constructor(DI\string('{root_directory}/test.json'), DI\create('Bar')), ]; ``` -------------------------------- ### Register Definitions Using Array Source: https://php-di.org/doc/container-configuration Shows how to register definitions directly within an array when creating the container. This method allows for inline configuration of dependencies and services. ```php $container = new DI\Container([ // place your definitions here ]); ``` -------------------------------- ### PHP-DI: Setting entries on the container with set() Source: https://php-di.org/doc/container Entries can be directly set on the container using the 'set()' method. For closures, use \DI\value to prevent them from being interpreted as factories. While direct setting is possible, using definition files is the recommended approach for managing container configurations. ```PHP $container->set('foo', 'bar'); $container->set('MyInterface', \DI\create('MyClass')); // Use \DI\value if you need to set a closure as raw value, // because closures are interpreted as factories by default $container->set('myClosure', \DI\value(function() { /* ... */ })); ``` -------------------------------- ### Injecting Symfony Services into PHP-DI Configuration Source: https://php-di.org/doc/frameworks/symfony2 Example of how to configure PHP-DI to inject services managed by Symfony's container into your PHP-DI-managed services. This is done by referencing Symfony service IDs within the PHP-DI configuration. ```php return [ 'AppBundle\Controller\ProductController' => DI\create() ->constructor(DI\get('doctrine.orm.entity_manager')), ]; ``` -------------------------------- ### Symfony Routing Configuration for Controller as Service Source: https://php-di.org/doc/frameworks/symfony2 Example of routing configuration in Symfony to map a route to a controller action. It demonstrates using the `service_id:method` format, which is crucial for PHP-DI to correctly resolve the controller from the container. ```yaml my_route: pattern: /product-stock/clear defaults: { _controller: MyBundle\Controller\ProductController:clearAction } ``` -------------------------------- ### PHP-DI: Dependency Injection in Callables via Explicit Definition Source: https://php-di.org/doc/container Shows how to inject dependencies into a callable using explicit definitions, either by parameter name or by directly providing the DI definition. This allows injecting container entries like database host configurations. ```PHP $container->call(function ($dbHost) { // ... }, [ // Either indexed by parameter names 'dbHost' => \DI\get('db.host'), ]); $container->call(function ($dbHost) { // ... }, [ // Or not indexed \DI\get('db.host'), ]); ``` -------------------------------- ### Register Middleware with PHP-DI and Silex Source: https://php-di.org/doc/frameworks/silex Illustrates how to register middleware in Silex using PHP-DI. Similar to controllers, middleware can be defined as classes, and PHP-DI will instantiate them and inject dependencies when the middleware is executed. This example shows registering a 'beforeRoute' middleware. ```php class AuthMiddleware { public function beforeRoute(Request $request, Application $app) { // ... } } $app->before([AuthMiddleware::class, 'beforeRoute']); ``` -------------------------------- ### Migrate Container Configuration: Annotations to Attributes Source: https://php-di.org/doc/migration/7.0 Shows how to configure PHP-DI to use PHP 8 attributes instead of annotations for dependency injection. This involves changing `useAnnotations(true)` to `useAttributes(true)` in the `ContainerBuilder` setup. ```PHP (Before) // Container configuration $containerBuilder = new \DI\ContainerBuilder; $containerBuilder->useAnnotations(true); ``` ```PHP (After) // Container configuration $containerBuilder = new \DI\ContainerBuilder; $containerBuilder->useAttributes(true); ``` -------------------------------- ### Recommended Configuration Layout for ZF1 Source: https://php-di.org/doc/frameworks/zf1 Illustrates a standard directory structure for application configuration files when using PHP-DI with Zend Framework 1. It highlights the placement of DI configuration, environment-specific settings, and local parameters. ```text application/ configs/ application.ini # ZF config config.php # DI config config.development.php # DI config for development config.production.php # DI config for production parameters.php # Local parameters (DB password, …) -> Don't commit this file parameters.php.default # Template for parameters.php -> Commit this file Bootstrap.php ``` -------------------------------- ### Create Slim Application with PHP-DI Bridge Source: https://php-di.org/doc/frameworks/slim Demonstrates how to create a Slim application instance using PHP-DI's Bridge class. This replaces the default Slim AppFactory and allows for PHP-DI's container to manage dependencies. An optional pre-configured container can be passed to the create method. ```php