承接 icanboogie/service 相关项目开发

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

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

icanboogie/service

Composer 安装命令:

composer require icanboogie/service

包简介

A dependency-injection container agnostic service provider

README 文档

README

Release Build Status Code Quality Code Coverage Packagist

ICanBoogie/Service provides means to reference, resolve, and invoke services using your favorite dependency injection container, in the most transparent way possible.

Please, consider the following example:

<?php

use ICanBoogie\Service\ServiceProvider;
use function ICanBoogie\Service\ref;

ServiceProvider::define(function ($id) {

	if ($id === 'hello')
	{
		return function ($name = "world") {
			return "Hello $name!";
		};
	}

	throw new \LogicException("Unknown service: $id");
});

# getting a service through the provider
$service = ServiceProvider::provide('hello');
echo $service("Madonna");
// Hello Madonna!

# using a reference
$reference = ref('hello');
echo $reference;
// hello
echo $reference("Madonna");
// Hello Madonna! 

References are callables

Service references created with ref are especially useful when you need to provide a callable but you don't want that callable to be instantiated right away:

<?php

use function ICanBoogie\Service\ref;

class Compute
{
	public function __construct(callable $computer)
	{
		// …
	}

	// …
}

$compute = new Compute(ref('expansive_instance'));

References can be exported

ServiceReference instances can safely be exported with var_export():

<?php

use ICanBoogie\Service\ServiceReference;

$id = 'my_service';
$reference = new ServiceReference($id);
$dump = var_export($reference, true);

$r = eval("return $dump;");

echo get_class($r);   // ICanBoogie\Service\ServiceReference 
echo (string) $r;     // my_service

Requirements

The package requires PHP 5.6 or later.

Installation

The recommended way to install this package is through Composer:

$ composer require ICanBoogie/Service

Cloning the repository

The package is available on GitHub, its repository can be cloned with the following command line:

$ git clone https://github.com/ICanBoogie/Service.git

Documentation

The package is documented as part of the [ICanBoogie][] framework documentation. You can generate the documentation for the package and its dependencies with the make doc command. The documentation is generated in the build/docs directory. ApiGen is required. The directory can later be cleaned with the make clean command.

Testing

The test suite is ran with the make test command. PHPUnit and Composer need to be globally available to run the suite. The command installs dependencies as required. The make test-coverage command runs test suite and also creates an HTML coverage report in build/coverage. The directory can later be cleaned with the make clean command.

The package is continuously tested by Travis CI.

Build Status Code Coverage

License

ICanBoogie/Service is licensed under the New BSD License - See the LICENSE file for details.

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固