osflab/container 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

osflab/container

Composer 安装命令:

composer require osflab/container

包简介

OSF dynamic object container mechanism

README 文档

README

OSF Container manages instances of your classes in order to optimize performance and accessibility. Define the instantiation policy of each class and let OSF Container create and manage your objects.

Features

  • Lazy classes instanciations
  • Optimized management of the instantiation policy
  • Dependency management
  • Mock objects generation & advanced mocking policy
  • Extremely simplified access to objects

Installation

You need at least php 7.1 and composer:

sudo apt install composer

In your application via composer

This is the recommended way to use this feature in a non-osf project.

Just add osflab/container in your composer.json file.

From github

To test the component or participate in its development.

git clone https://github.com/osflab/container.git
cd container && composer update

Unit tests launch:

vendor/bin/runtests

Usage

For example, to use Osf\Cache component (anyware in your code):

$cache = \Osf\Container\OsfContainer::getCache();

To create your own container:

use Osf\Container\AbstractContainer;

class MyContainer extends AbstractContainer
{
    /**
     * Build and get on-demand \My\Class instance(s)
     * @return \My\Class
     */
    public static function getMyClass(): \My\Class
    {
        return self::buildObject('\My\Class');
    }
}

The AbstractContainer::buildObject() method takes 3 args:

  • The class name
  • An array of class constructor values
  • A namespace string

See OsfContainer, ZendContainer and VendorContainer for more examples.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: AGPL-3.0-or-later
  • 更新时间: 2018-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固