proklung / bitrix-containerable-boilerplate
PHP boilerplate 用于在 Bitrix 中使用 Symfony 容器
1.1.6
2021-08-20 05:43 UTC
Requires
- php: >=7.1 | ^8.0
- symfony/config: ^4.4 || ^5.0
- symfony/console: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/filesystem: ^4.4 || ^5.0
Requires (Dev)
README
内部
安装
composer.json
"repositories": [ { "type": "git", "url": "https://github.com/proklung/bitrix.containerable.boilerplate" } ]
composer require proklung/bitrix-containerable-boilerplate
其他
如何加载包
- 从文件
配置文件,类似于 Symfony
return [ Prokl\MyBundle\MyBundle::class => ['all' => true], ]
$bundlesConfigFile = __DIR_. '../../config/bundles.php' //... // Важно - перед загрузкой сервисов! $loaderBundles = new LoaderBundles( static::$container, $this->environment ); $loaderBundles->fromFile($bundlesConfigFile);
- 从目标模块的
bundles
部分
use Bitrix\Main\Config\Configuration; //... $this->config = Configuration::getInstance()->get('my.module') ?? ['my.module' => []]; $this->bundles = $this->config['bundles'] ?? []; //... // Важно - перед загрузкой сервисов! $loaderBundles = new LoaderBundles( static::$container, $this->environment ); $loaderBundles->fromArray($this->bundles);