承接 icanboogie/bind-symfony-dependency-injection 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

icanboogie/bind-symfony-dependency-injection

最新稳定版本:v5.0.0

Composer 安装命令:

composer require icanboogie/bind-symfony-dependency-injection

包简介

Binds symfony/dependency-injection to ICanBoogie

README 文档

README

Release Code Coverage Downloads

Together with icanboogie/service, this package binds symfony/dependency-injection to ICanBoogie and allows the container to be used to provide services.

Obtaining services

Services can be obtained using a service reference or the container.

The following example demonstrates how services can be obtain using references:

<?php

use function ICanBoogie\Service\ref;

$reference = ref('a_callable_service');
$result = $reference(1, 2, 3);

$reference = ref('a_service');
$service = $reference->resolve();
$service->do_something();

The following example demonstrates how a service can be obtained using the container itself:

<?php

/* @var $app \ICanBoogie\Application */
/* @var $container \Symfony\Component\DependencyInjection\Container */

$container = $app->container;
$service = $container->get('a_service');
$service->do_something();

Obtaining services bound to the application

Usually, ICanBoogie's components add getters to ICanBoogie\Application instances through the prototype system, which means you can access the initial request using $app->initial_request or the session using $app->session. Services defined this way are automatically accessible through the container as well, which means they can be used as references ref('session') or obtained through the container $app->container->get('session').

Obtaining config parameters

All application config parameters are available as container parameters e.g. $app->container->getParameter('app.repository.cache)`.

Note: To avoid clashes, all application parameters are prefixed with app..

Defining services

Services are defined using services.yml files in config folders. They are collected when it's time to create the container, just like regular configuration files.

The tests included in this package showcase how services.yml files can be defined in all/config and default/config. Components and modules can use this feature to register their own services and make them available to the application automatically.

About the container proxy

The service provider defined during Application::boot is an instance of ContainerProxy, which only builds the service container when a service needs to be resolved.

The following example demonstrates how the service provider and the service container can be obtained:

<?php

use ICanBoogie\Service\ServiceProvider;

/* @var $proxy \ICanBoogie\Binding\SymfonyDependencyInjection\ContainerFactory */

$proxy = ServiceProvider::defined();
$container = $proxy->container;

Configuring the container

The container is configured using container configuration fragments:

<?php

// config/container.php

use ICanBoogie\Binding\SymfonyDependencyInjection\ConfigBuilder;
use ICanBoogie\Binding\SymfonyDependencyInjection\Extension\ApplicationExtension;

return fn(ConfigBuilder $config) => $config
    ->add_extension(ApplicationExtension::class)
    ->enable_caching();

Continuous Integration

The project is continuously tested by GitHub actions.

Tests Static Analysis Code Style

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you're expected to uphold this code.

Contributing

See CONTRIBUTING for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-02-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固