glenjamin/dimple 问题修复 & 功能扩展

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

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

glenjamin/dimple

Composer 安装命令:

composer require glenjamin/dimple

包简介

Dirt simple dependency injection container

README 文档

README

Dirt simple dependency injection container based loosely on Pimple

Install

composer require glenjamin/dimple

Usage

$di = new \Dimple\Dimple();

$di->setup('app', function($di) {
    return new Application($di->get('db'), $di->get('logger'));
});

$di->setup('db', function($di) {
    return new \PDO($di->get('db-string'));
});

$di->set('dbstring', 'mysql://localhost');
$di->setup('logger', function($di) {
    return new Logger($di->get('logfile', '/dev/null'));
});

$app = $di->get('app');
$app->run();

How do I return the same instance on subsequent calls?

You don't.

Is it fast?

Unfortunately not massively, although it's not too bad

> php benchmark.php
10000000 Iterations
Raw: 4.3745291233063
Dimpled: 14.07391500473

Overhead: 221.724113%

It's a little over two times slower than raw object initialisation. If you use it for only your service level objects it should be palatable.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-07-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固