定制 mulertech/container 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mulertech/container

最新稳定版本:1.1.1

Composer 安装命令:

composer require mulertech/container

包简介

The MulerTech dependency injection container

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub PHPStan Action Status GitHub Security Action Status Total Downloads Test Coverage

The MulerTech dependency injection container

Installation

Two methods to install Application package with composer :

Add to your "composer.json" file into require section :

"mulertech/container": "^1.0"

and run the command :

php composer.phar update

Run the command :

php composer.phar require mulertech/container "^1.0"

Usage


Initialize the container (you can give the definitions into this construct) :
$container = new Container();
or
$container = new Container($definitions);
//definitions file :
return [
new \MulerTech\Container\Definition(\Psr\Http\Server\RequestHandlerInterface::class, \MulerTech\Application\RequestHandler::class),
new \MulerTech\Container\Definition(\MulerTech\Form\Validators\MaxLengthValidator::class, null, [], true)
];

Get simple class :
$container->get(Foo::class);

Add a class with its interface (you can get this class with the interface class name) :
$container->add(FooInterface::class, Foo::class);

$fooClass = $container->get(FooInterface::class);

Add a class with arguments :
$container->add(FooInterface::class, Foo::class, ['argumentName' => 'argument value']);

Set parameters and get it :
$container->setParameter('parameter', 'a value');

echo $container->getParameter('parameter'); // a value

Use parameters into class construct arguments :
$container->setParameter('parameter', 'a value');

$container->add(FooInterface::class, Foo::class, ['argumentName' => '%parameter%']);

Load yaml files parameters into container :
$container = new Container();
$loader = new Loader();
$loader
    ->setFileList(['./path_to_files/file1.yaml', './path_to_files/file2.yaml'])
    ->setLoader(YamlLoader::class)
    ->loadParameters($container);

Set parameters with env value :
#env file :
key=value
$container = new Container();
$container->setParameter('parameter', 'env(key)');
echo $container->getParameter('parameter'); // value

统计信息

  • 总下载量: 380
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-10-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固