承接 laravelba/proxyvel 相关项目开发

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

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

laravelba/proxyvel

Composer 安装命令:

composer require laravelba/proxyvel

包简介

Service proxy for laravel's IoC container

README 文档

README

An implementation of ProxyManager for Laravel.

Why?

When you do intensive constructor injection, a lot of objects will be needed in order to create your application. As php creates all your environment for each request, this is a lot of heavy lifting for php to do, and probably most of your object graph won't be used anyway.

This package helps you by giving you proxies instead of real objects.

For a way better explanation of this, read what @Ocramius has to say about it or head to the ProxyManager documentation

Usage

Laravel's architecture is not flexible on the IoC container: The Illuminate\Foundation\Application object extends the Illuminate\Container\Container and that makes it hard to swap out.

This package provides two extensions, namely of Application and Container. You probably won't need both.

Also, this package provides a way to decide which objects will be proxied by the IoC container, through the Specification pattern:

// Proxy all the things!
$specification = new Proxyvel\Specifications\ProxyEverything;

// Proxy by the given namespaces
$specification = new Proxyvel\Specifications\ProxyNamespace([
    'App\Services',
    'App\Repositories'
]);

// Proxy only the given cases / class names
$specification = new Proxyvel\Specifications\ProxyCases([
    // You can always proxy Laravel's services by using the key Laravel sets
    'db',
    // Proxy some concrete classes
    'App\Services\FooService',
    // And some interfaces
    'App\Contracts\FooRepositoryInterface'
]);

// Proxy by regular expression (powerful, but usually complex)
$specification = new Proxyvel\Specifications\ProxyByRegExp([
    '/Interface$/', '/^Abstract/'
]);

// Combine multiple specifications
$specification = new Proxyvel\Specifications\ProxyCollection([
    new Proxyvel\Specifications\ProxyCases(/* ... */),
    new Proxyvel\Specifications\ProxyNamespace(/* ... */),
]);

// Define by negation (for those of you who see the glass half-empty)
$specification = new Proxyvel\Specifications\ProxyNegator(
    new Proxyvel\Specifications\ProxyNamespace('App\Entities')
);

Usage in a Laravel project

There's no ServiceProvider here. You'll need to edit your bootstrap/start.php file, and replace the $app variable with this package's Application:

// in bootstrap/start.php 
$app = new Proxyvel\Application;

// If you don't call this, the container will just defer to Laravel's default behavior
$app->setProxyConfiguration(
    // Example Specification, build the one you need here
    new Proxyvel\Specifications\ProxyEverything,
    // Only instances of AbstractLazyFactory are accepted for now
    new ProxyManager\Factory\LazyLoadingValueHolderFactory
);

In a Laravel project, every instance of Container is resolved with the initial Application, so that's the only thing you'll ever need.

Usage outside of a Laravel project

If you use Laravel's Container outside of a Laravel project, you'll need to instantiate this package's Container extension instead.

// Wherever you first instantiate it
$container = new Proxyvel\Container(
    // Example Specification, build the one you need here
    new Proxyvel\Specifications\ProxyEverything,
    // Only instances of AbstractLazyFactory are accepted for now
    new ProxyManager\Factory\LazyLoadingValueHolderFactory
);

Because of Liskov's substitution principle, this package's extension can be used in any place the Container is expected.

laravelba/proxyvel 适用场景与选型建议

laravelba/proxyvel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 99 次下载、GitHub Stars 达 1, 最近一次更新时间为 2015 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 laravelba/proxyvel 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-02-19