zofe/deficient
Composer 安装命令:
composer require zofe/deficient
包简介
Experimental subset of laravel components
README 文档
README
Deficient give you some of laravel components, without the entire environment.
You can also add some other package because I keepd the IOC and service-provider booting.
It has also some helper to keep a concise syntax.
Basically you'll get:
- eloquent
- validation
- translation
- blade
- burp (a tiny, non blocking, router)
why
In some cases, with big projects, you can't switch to Laravel from start, you need to move step by step, section by section. In some other, you need just a great ORM, or/and template engine, or form validation, translations.. but not a "framework".
Think to "deficient" as a way to use laravel without move to laravel, or (better) a way to embrace laravel slowly and quietly using each component when, where and how you like in your current app.
On the other hand:
- deficient make a vendor of 3.5 mb
- laravel build a vendor of 20 mb
(using illuminate components of 4.1 --prefer-dist version for both)
Installation
install via composer creating or adding dependency to your composer.json:
{
"require": {
"zofe/deficient": "dev-master"
}
}
then running composer install
usage
you can setup a basic file structure, to store configurations, views, language files, and models.
The suggestd one is:
/config
app.php
database.php
/lang
/en
validation.php
/models
User.php
/cache
/views
hello.blade.php
To create this structure you can simply run a setup command:
(important: be sure that you've no folders conflict with your current application)
php vendor/zofe/deficient/deficient setup:folders
You must set write permission to /cache folder.
Then you can make an index.php in your root or use Deficient where you want in your project:
<?php #index.php require_once __DIR__ . '/vendor/autoload.php'; use Zofe\Deficient\Deficient; //booting from current directory (needed to find config and other folders) Deficient::boot("./"); //db stuff $results = select('select * from mytable'); //validation $validator = validator(array('title'=>'abc','description'=>'description bla b...'), array('title'=>'required|min:4','description'=>'required')); if ($validator->fails()){ dd( $validator->messages() ); } //translation (return 'thankyou' value @ current locale: /lang/en/messages.php ) echo trans('messages.thankyou'); //eloquent $users = User::all(); //blade echo blade('hello', compact('results','users'));
Laravel Facades
You can also use laravel Facades, declaring or using full namespaces, i.e.:
<?php use Zofe\Deficient\Deficient; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\DB; ... $validator = Validator::make(.... $results = DB::select(....
Need a Router?
Deficient comes without laravel router, but it has simple alternative: burp router.
So you can do something like this:
.. Deficient::boot("./"); route_get('^/user/(\d+)$', function( $id ) { $user = User::find($id); echo blade('user_detail', compact('user')); }); route_post('^/user/(\d+)$', function( $id ) { $user = User::find($id)->update($_POST); echo blade('user_detail', compact('user')); }); route_missing(function() { echo blade('error', array(), 404); die; }); route_dispatch();
To create a basic index.php, .htaccess, and some route you can use this command
(important: be sure that you've no index.php and .htaccess in your current application)
php vendor/zofe/deficient/deficient setup:router
zofe/deficient 适用场景与选型建议
zofe/deficient 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 81 次下载、GitHub Stars 达 6, 最近一次更新时间为 2014 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「cms」 「mvc」 「modules」 「eloquent」 「blade」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 zofe/deficient 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 zofe/deficient 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 zofe/deficient 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Kinikit - PHP Application development framework MVC component
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Integrate with Snipcart.
Follow, Favourite, Bookmark, Like & Subscribe.
统计信息
- 总下载量: 81
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-10-19