aedart/laravel-helpers
最新稳定版本:5.1.0
Composer 安装命令:
composer require aedart/laravel-helpers
包简介
Getters and Setters utility package for some of Laravel's core packages. This package make use of Laravel's native Facades, as a fallback, when no custom instances are provided.
README 文档
README
Deprecated - Laravel Helpers
Package has been replaced by aedart/athenaeum
Getters and Setters utility package for some of Laravel's core packages.
This package make use of Laravel's native Facades, as a fallback, when no custom instances are provided.
Contents
- When to use this
- When not to use this
- How to install
- Quick start
- Contribution
- Acknowledgement
- Versioning
- License
When to use this
- When your component depends on one or several of Laravel's native components
- When there is a strong need to interface such dependencies
- When you need to be able to set a different instance of a given native Laravel component, e.g. your implemented version of a Configuration Repository
When not to use this
If you are using a modern IDE, then the added PHPDoc will ensure code-hinting of the various methods' return type. However, you shouldn't blindly use these helpers, just for the sake of gaining code-hinting, for Laravel's Facades. If you are just seeking that, then perhaps Barry vd. Heuvel's Laravel IDE Helper Generator package, is a far better solution for you.
How to install
composer require aedart/laravel-helpers
This package uses composer. If you do not know what that is or how it works, I recommend that you read a little about, before attempting to use this package.
Quick start
Component-aware interface, and component-trait
Lets imagine that you have some kind of component, that needs to be aware of a configuration repository. You can ensure such, by implementing the ConfigAware interface.
Furthermore, a default implementation is available, via the ConfigTrait trait.
<?php use Aedart\Laravel\Helpers\Contracts\Config\ConfigAware; use Aedart\Laravel\Helpers\Traits\Config\ConfigTrait; class MyComponent implements ConfigAware { use ConfigTrait; }
Now, your component is able to set and get an instance, of Laravel's \Illuminate\Contracts\Config\Repository. This means that, if you have a custom implementation of such a repository, then
you can specify it on the component;
<?php // Somewhere in you application... $myComponent = new MyComponent(); $myComponent->setConfig($myCustomConfigRepository);
Default fallback to Laravel's Facades
All traits have a default fallback method, which invokes Laravel's corresponding facades, ensuring that even if you do not specify an instance, a given component is returned;
<?php // When no custom configuration repository has been specified... $myComponent = new MyComponent(); $configRepository = $myComponent->getConfig(); // Uses fallback, invokes the `\Illuminate\Support\Facades\Config`, which is then resolved from the IoC Service Container
Usage inside a Laravel application
You do not need any special configuration or service provides. Just ensure that you have required this package as a dependency, and you are good to go.
Outside a Laravel application
If you plan to use this package outside a Laravel application, then you might require additional dependencies.
Example
If you need to work with the filesystem components, then you must require Laravel's filesystem package;
composer require illuminate/filesystem
IoC Service Container - no fallback
Fallback is not available, for any of the implemented traits, if this package is used outside a Laravel Application. It is up to you, to provide a fallback, if such is needed.
Should that be the case, then you can overwrite the getDefaultXZY methods, in your component.
<?php use Aedart\Laravel\Helpers\Contracts\Config\ConfigAware; use Aedart\Laravel\Helpers\Traits\Config\ConfigTrait; use Illuminate\Contracts\Config\Repository; use Illuminate\Config\Repository as ConfigRepo; class MyComponent implements ConfigAware { use ConfigTrait; public function getDefaultConfig() : Repository { return new ConfigRepo(); // Please note that this repository will NOT store values statically! } }
As an alternative, you can also bind your dependencies and still use the facades. Read more about Laravel's IoC Service Container, in order to learn more about this.
Contribution
Have you found a defect ( bug or design flaw ), or do you wish improvements? In the following sections, you might find some useful information on how you can help this project. In any case, I thank you for taking the time to help me improve this project's deliverables and overall quality.
Bug Report
If you are convinced that you have found a bug, then at the very least you should create a new issue. In that given issue, you should as a minimum describe the following;
- Where is the defect located
- A good, short and precise description of the defect (Why is it a defect)
- How to replicate the defect
- (A possible solution for how to resolve the defect)
When time permits it, I will review your issue and take action upon it.
Fork, code and send pull-request
A good and well written bug report can help me a lot. Nevertheless, if you can or wish to resolve the defect by yourself, here is how you can do so;
- Fork this project
- Create a new local development branch for the given defect-fix
- Write your code / changes
- Create executable test-cases (prove that your changes are solid!)
- Commit and push your changes to your fork-repository
- Send a pull-request with your changes
- Drink a Beer - you earned it :)
As soon as I receive the pull-request (and have time for it), I will review your changes and merge them into this project. If not, I will inform you why I choose not to.
Acknowledgement
- Taylor Otwell, for creating Laravel and especially the Service Container, that I'm using daily
- Jeffrey Way, for creating Laracasts - a great place to learn new things... E.g. how facades work!
Versioning
This package follows Semantic Versioning 2.0.0
License
BSD-3-Clause, Read the LICENSE file included in this package
aedart/laravel-helpers 适用场景与选型建议
aedart/laravel-helpers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.04k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 09 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「helpers」 「laravel」 「facade」 「getters」 「setters」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aedart/laravel-helpers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aedart/laravel-helpers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aedart/laravel-helpers 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
HTML and form generation
Falsy helps you manage half-truths with PHP
A Laravel wrapper and facade package for the Trello API
Simple PHP building block framework
provides an facade for php-yaml, syck and symphony/yaml so switching in between is easier
Git manager and platform provider for Laravel — facades, typed DTOs, test fakes, and scoped repositories.
统计信息
- 总下载量: 1.04k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-09-24