承接 flexsounds/slim-symfony-di-container 相关项目开发

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

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

flexsounds/slim-symfony-di-container

Composer 安装命令:

composer require flexsounds/slim-symfony-di-container

包简介

The bridge to use the Symfony Dependency Injection Container to use in Slim Framework 3

README 文档

README

Travis Build Status Packagist Packagist

Slim-Symfony-Dependency-Injection-Bridge

Just a simple bridge to use the Symfony Dependency Injection Container to replace the Container in Slim Framework 3

This will replace the pimple container which comes default with Slim Framework 3.

The default services (like router, request, response) which Slim Framework uses, are preloaded in the ContainerBuilder. This way Slim will work as it should.

Installation

Use composer to install

composer require flexsounds/slim-symfony-di-container

Default usage

To use the Symfony DI Container just add the ContainerBuilder to Slim\App

$container = new \Flexsounds\Component\SymfonyContainerSlimBridge\ContainerBuilder();

$app = new \Slim\App($container);

// define your routes here. The container is available through $this in the route closure

$app->run();

Default parameters

The default Slim Framework Settings are 1 on 1 mapped with parameters. To overwrite the settings you can either create a new ParameterBag with your settings and pass it as the first argument to the ContainerBuilder. Or if you use one of the file loaders, change them with the parameters config key.

Just change the parameters to your own choice to your config file like this.

parameters:
   httpVersion: "1.1"
   responseChunkSize: 4096
   outputBuffering: "append"
   determineRouteBeforeAppMiddleware: false
   displayErrorDetails: false

Other Examples

Example loading your dependencies through yaml configuration (The Symfony way)

$container = new \Flexsounds\Component\SymfonyContainerSlimBridge\ContainerBuilder();
$loader = new \Symfony\Component\DependencyInjection\Loader\YamlFileLoader($container, new \Symfony\Component\Config\FileLocator(__DIR__));
$loader->load('config.yml');

$app = new \Slim\App($container);

$app->run();

Now you can create a config.yml file to load your services, parameters, etc. The use of importing other config files is also available.

services:
  my.custom.service:
    class: Location\To\The\Class

Now the service my.custom.service is available in the container. Use $this->get('my.custom.service') to load the service.

$app->get('/', function($request, $response){
  $customService = $this->get('my.custom.service'); // $customService is now an instance of Location\To\The\Class()
});

Read more

Read the symfony service container documentation to find out what other options are available in the service container.

Read the symfony dependency injection documentation to find out how the ContainerBuilder is used. Like setting default parameters.

Interesting to know

If you use PhpStorm as IDE and add the Symfony Plugin, typehinting for services should be available.

flexsounds/slim-symfony-di-container 适用场景与选型建议

flexsounds/slim-symfony-di-container 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 49.35k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2016 年 01 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 flexsounds/slim-symfony-di-container 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 flexsounds/slim-symfony-di-container 我们能提供哪些服务?
定制开发 / 二次开发

基于 flexsounds/slim-symfony-di-container 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 49.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-14