
PHP-DI - The Dependency Injection Container for humans
PHP-DI provides the classic API of a container as well as advanced features useful to build or extend a framework. PHP-DI is compliant with PSR-11: $container->has($name);
《PHP-DI 中文文档》 | PHP 技术论坛 - LearnKu
PHP-DI 是一个依赖注入容器,旨在实用,强大且与框架无关。 第一章. 基础信息. 1.1. 翻译说明. 第二章. Introduction. 2.1. Getting started 已完成. 2.2. Understanding dependency injection 已完成. 2.3. 最佳实践指南 已完成. 第三章. Usage. 3.1. Configure the container 已完成. 3.2. Use the container 已完成. 第四章. Definitions. 4.1. Introduction 已完成. 4.2. Autowiring 已完成. 4.3. PHP definitions 已完成. 4.4. Annotations 已完成. 4.5.
PHP-DI/PHP-DI: The dependency injection container for humans - GitHub
PHP-DI is a dependency injection container meant to be practical, powerful, and framework-agnostic. Read more on the website: php-di.org. Available as part of the Tidelift Subscription.
开始使用 · PHP-DI中文文档 · 看云 - kancloud.cn
欢迎!这份指南将帮助你在项目中使用PHP-DI. 在开始之前,你需要知道什么是 依赖注入. 如果你不知道,这一整篇文章就是为了它: 了解依赖注入. Install PHP-DI with Composer: PHP-DI 需要 PHP 5.5以上版本. 1. 使用依赖注入. 第一,让我们写使用依赖注入的代码而不用其考虑PHP-DI. public function mail($recipient, $content) { // send an email to the recipient } } private $mailer; . public function __construct(Mailer $mailer) { . $this->mailer = $mailer; }
PHP-DI中文文档(基于有道翻译,基本是直接拿过来使用,并没 …
2019年11月15日 · PHP-DI requires PHP 7.0 or above. (PHP-DI需要PHP 7.0或者更高) (基本用法) 1. Use dependency injection. (使用依赖注入) First, let's write code using dependency injection without thinking about PHP-DI: (首先,让我们在不考虑PHP-DI的情况下使用依赖注入编 …
[PHP-DI] 理解依赖注入 - 姜小豆 - 博客园
2018年4月7日 · 使用 PHP-DI. 你可能会发现依赖注入会带来一个缺点:你现在必须处理注入依赖关系。 这就是容器(Container),特别是PHP-DI可以帮助你的地方。 而不是写: $geolocationService = new GoogleMaps(); $storeService = new StoreService($geolocationService); 你可以写: $storeService = $container->get ...
PHP-DI中文文档(基于有道翻译,基本是直接拿过来使用,并没 …
2018年4月20日 · PHP-DI requires PHP 7.0 or above. (基本用法) 1. Use dependency injection. class UserManager { private $mailer; public function __construct(Mailer $mailer) { $this->mailer = $mailer; } public function register($email, $password) { // The user just registered, we …
PHP-DI/doc/getting-started.md at master - GitHub
If you want to use PHP-DI with another framework or your own code, try to use $container->get() in you root application class or front controller. Have a look at this demo application built around PHP-DI for a practical example.
PHP-DI 使用教程 - CSDN博客
2024年9月5日 · PHP-DI 是一个面向人类的依赖注入容器,旨在实用、强大且与框架无关。 它完全兼容 PSR-11 标准,使得它能够轻松集成到任何遵循该标准的项目中。 PHP-DI 支持自动装配、注解配置以及通过代码配置等多种配置方式,极大地简化了依赖管理和对象创建过程。 return "Hello, World!"; echo $service -> sayHello (); // 输出: Hello, World! 假设我们有一个电子商务网站,需要管理用户、产品和订单。 我们可以使用 PHP-DI 来管理这些服务的依赖关系: 使用自动装配: …
php di,PHP-DI中文文档(基于有道翻译,基本是直接拿过来使 …
2021年3月11日 · 本文是PHP-DI的入门指南,介绍了如何在项目中使用PHP-DI进行依赖注入。首先,你需要了解依赖注入的基本概念。然后,通过Composer安装PHP-DI,并通过创建容器实例和配置对象来使用它。PHP-DI利用autowiring技术自动解析类的依赖关系,减少手动配置。
- 某些结果已被删除