Package Data | |
---|---|
Maintainer Username: | yangze |
Maintainer Contact: | zhenyangze@gmail.com (zhenyangze) |
Package Create Date: | 2019-02-24 |
Package Last Update: | 2019-03-06 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-02-06 15:03:23 |
Package Statistics | |
---|---|
Total Downloads: | 11 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
在laravel框架中支持Lumen的运行,运行模式包含php-fpm和swoole两种模式。
Lumen可以使用Laravel框架大分部代码,包含配置,路由,控制器,模型,集合,缓存,队列,事件
目前代码先在laravel5.5中测试 在仓库swooletw/laravel-swoole基础上修改 貌似注意事项好多,有问题请留言
务必注意Lumen bug,看本页Lumen bug说明
1、安装包
composer require yangze/lamen --prefer-dist
2、修改config/app.php,添加provider引用
Lamen\Http\LaravelServiceProvider::class
3、发布配置文件
php artisan vendor:publish --tag=lamen-swoole
4、修改config/lamen.php文件(重要,影响程序运行)
| 键 | 名称 | 值 | |--------|--------|--------| |FRAME_WORK_NAME|当前框架的名称|laravel 或者 lumen|
5、运行 以laravel模型运行
php artisan lamen:http start
以lumen模式运行
php artisan_lumen lamen:http start
以nginx+php-fpm模式运行
注意修改public/lamen.php文件,将其设置为入口文件。有2种方法,2选1:
1、路由正则配置模式有差别,在针对lumen的路由中不要出现laravel路由相应的写法,否则会提示route找不到或者为空的情况
2、laravel中获取路由参数和Lumen中获取路由参数不一样,需要写兼容方法调用 在lumen的collection或者middleware中使用request()->get(),request()->all(),
需要修改成
$route=$request->route();
$route[2]['url参数'];
在post中可以使用request()->input
3、Lumen bug
Type error: Too few arguments to function Illuminate\Cache\Console\ClearCommand::__construct(), 1 passed in vendor/laravel/lumen-framework/src/Console/ConsoleServiceProvider.php on line 113 and exactly 2 expected
修改文件: vendor/laravel/lumen-framework/src/Console/ConsoleServiceProvider.php
,将代码
protected function registerCacheClearCommand()
{
$this->app->singleton('command.cache.clear', function ($app) {
return new CacheClearCommand($app['cache']);
});
}
修改为:
protected function registerCacheClearCommand()
{
$this->app->singleton('command.cache.clear', function ($app) {
return new CacheClearCommand($app['cache'], $app['files']);
});
}