定制 getsky/phalcon-autoload-services 二次开发

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

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

getsky/phalcon-autoload-services

Composer 安装命令:

composer require getsky/phalcon-autoload-services

包简介

Components for automatic registration services in Dependency Injection

README 文档

README

This component allows to register services in DI with the settings file.

The main features of the component:

  • Services can be initialized with a string, object or service provider;
  • Services are connected via a configuration file;
  • Services can be registered as "shared" services;

Requirements:

  • PHP 5.4
  • Phalcon Framework

Phalcon framework: http://phalconphp.com/

Using

For registration services necessary to execute the code:

$services = new Ini('services.ini');
$dic = new FactoryDefault();

$registrant = new Registrant($services);
$registrant->setDi($dic);
$registrant->registration();

Configuring Services

There are three ways to register services:

  1. By the class name. This method does not allow to pass arguments to a constructor or adjust parameters.

    [response]
    string = "Phalcon\Http\Response"
  2. Registering an instance directly. When using this method the container is placed dependency already finished object.

    [request]
    object = "Phalcon\Http\Response"
  3. Through the service provider. Which must implement the interface GetSky\Phalcon\AutoloadServices\Provider. According to the plan, providers are intermediaries for registration of anonymous functions in the container dependency, but have the opportunity to realize any other way that supports Phalcon.

    [route]
    provider = "RouteProvider"

For the second and third method possible to specify which arguments are passed to the constructor and invoke methods since its inception and prior to placement in the DI. Below is an example of how it can be implemented on the ini:

[first-service]
provider = "SomeNamespace\FirstClass"
arg.0.service = "config"
arg.1.var = "24"
arg.2.di = 1
arg.3.s-service = "shared-service"
arg.4.object.object = "SoeNamespace\SecondClass"
arg.4.object.arg.0.var = "42"
arg.4.object.call.0.method = "run"

In the above example, we register the service SomeNamespace\FirstClass under the name first-service and pass 5 arguments: the service config, variable 24, DI (object implements DiInterface), service shared-services caused by the method getShared and an instance of SomeNamespace\SecondClass, which was first created with transfer 42 and calling run.

统计信息

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

GitHub 信息

  • Stars: 15
  • Watchers: 5
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-01-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固