lumen feature plus
本组件是作为 Lumen 框架服务的增强
-
替换
nikic/fast-route
为illuminate/routing
-
新增以下
make
命令make:controller
make:model
make:factory
make:middleware
make:command
event:generate
make:event
make:resource
-
新增路由缓存命令
router:cache
router:clear
执行以下命令
composer require mowangjuanzi/lumen-plus
使用 Mowangjuanzi\Plus\LumenPlusApplication
替换 bootstrap/app.php
中的 Laravel\Lumen\Application
, 即:
$app = new Mowangjuanzi\Plus\LumenPlusApplication(
dirname(__DIR__)
);
注册服务提供者
$app->register(Mowangjuanzi\Plus\LumenServiceProvider::class);
防止缓存文件被git
追踪
创建文件夹bootstrap/cache
,然后创建bootstrap/cache/.gitignore
,输入以下内容
*
!.gitignore
加载路由
接下来修改bootstrap/app.php
中加载路由的地方。
框架最开始是这样的:
$app->router->group([
'namespace' => 'App\Http\Controllers',
], function ($router) {
require __DIR__.'/../routes/web.php';
});
修改后变成这样:
if ($app->files->exists($app->basePath("bootstrap/cache/routes.php"))) {
require_once $app->basePath("bootstrap/cache/routes.php");
} else {
$app->router->group([
'namespace' => 'App\Http\Controllers',
], function ($router) {
require __DIR__.'/../routes/web.php';
});
}
然后我们就可以查看命令:
$ php artisan
Laravel Framework Lumen (6.3.3) (Laravel Components ^6.0)
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
migrate Run the database migrations
route
route:cache Create a route cache file for faster route registration
route:clear Remove the route cache file
route:list List all registered routes
缓存路由
php artisan router:cache
清除路由
php artisan router:clear
有什么问题可以来 issus.