cosmicvelocity/lumen-helpers
Composer 安装命令:
composer require cosmicvelocity/lumen-helpers
包简介
Improves interoperability between Lumen and Laravel.
README 文档
README
Improves interoperability between Lumen and Laravel.
Since Lumen started focusing on providing stateless APIs from 5.2, session etc etc has been removed. However, Lumen, which has a low processing speed, is also attractive for regular web application development.
Fortunately, Lumen can incorporate the components of Laravel and reintroduce the removed function. This library provides functions that are missing when you use Lumen like that.
In addition, it supports the upgrading of applications developed under Lumen 5.1, It can be used for improving implementation compatibility, assuming that you are planning to migrate to Laravel in the future.
Installation
If composer is used, it can be introduced by adding the following description.
{
"require": {
"cosmicvelocity/lumen-helpers": ">=1.0"
}
}
When using helpers related to sessions, Lumen needs to be set so that sessions can be used.
To enable sessions with Lumen 5.4, set the Application in bootstrap.php as shown below.
// Add required alias. $app->alias('cookie', \Illuminate\Cookie\CookieJar::class); $app->alias('cookie', \Illuminate\Contracts\Cookie\Factory::class); $app->alias('cookie', \Illuminate\Contracts\Cookie\QueueingFactory::class); $app->alias('session', \Illuminate\Session\SessionManager::class); $app->alias('session.store', \Illuminate\Session\Store::class); $app->alias('session.store', \Illuminate\Contracts\Session\Session::class); // Read the configuration file. // You need to prepare a configuration file similar to Laravel in config/session.php. $app->configure('session'); $app->withFacades(true, [ \Illuminate\Support\Facades\Config::class => 'Config' ]); // Set cookie, Session service provider. $app->register(\Illuminate\Cookie\CookieServiceProvider::class); $app->register(\Illuminate\Session\SessionServiceProvider::class); // Set middleware. $app->middleware([ \Illuminate\Cookie\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, ]);
How to use
The helper currently provided is as follows.
I will do the same operation as Laravel 's same name helper.
- abort_if
- abort_unless
- action
- app_path
- asset
- auth
- back
- bcrypt
- cache
- cookie
- csrf_field
- csrf_token
- logger
- method_field
- mix
- old
- policy
- public_path
- report
- session
- validator
In addition, we provide our own helper as below.
-
app_with: An app () compatible helper corresponding to makeWith call. illuminate/container: From 5.4, you can not pass $parameters to make, instead makeWith prepared, By using app_with, make can be done by passing parameters that ask Lumen, illuminate / container version.
-
redirect_with_session: Since the redirect helper from Lumen 5.2 onward does not take over the session, we provide redirect_with_session to inherit the session. However, it must be built in advance such as SessionServiceProvider and session must be enabled in Lumen.
return redirect_with_session(route('index')) ->withErrors($errors) ->withInput();
By using redirect_with_session, you will be expecting withErrors, withInput etc. If you want to replace redirect with redirect_with_session you can replace it with bootstrap/app.php as follows.
// Define redirect first. function redirect($to = null, $status = 302, $headers = [], $secure = null) { return redirect_with_session($to, $status, $headers, $secure); } require_once __DIR__ . '/../vendor/autoload.php';
cosmicvelocity/lumen-helpers 适用场景与选型建议
cosmicvelocity/lumen-helpers 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62.9k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 11 月 26 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「lumen」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cosmicvelocity/lumen-helpers 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cosmicvelocity/lumen-helpers 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cosmicvelocity/lumen-helpers 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Testing Suite For Lumen like Laravel does.
Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).
Class to generate a standard structure for api json responses
Amqp classes
Audit changes of your Eloquent models in Laravel/Lumen
Laravel, Lumen and Native php elasticseach query builder to build complex queries using an elegant syntax
统计信息
- 总下载量: 62.9k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-11-26