2018-10-18

lumen artisan支持的命令列表

使用两种方式创建项目

1. 通过 Lumen 安装器

创建项目

composer global require "laravel/lumen-installer"

将 ~/.composer/vendor/bin 路径加到环境变量中的 PATH ,只有这样系统才能找到 lumen 的可执行文件。

lumen new blog

2. 通过 Composer Create-Project 命令安装

composer create-project --prefer-dist laravel/lumen blog

运行程序

php -S localhost:8000 -t public

查看支持的文件列表

php artisan list

art list
Laravel Framework Lumen (5.7.1) (Laravel Components 5.7.*)

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
 auth
  auth:clear-resets   Flush expired password reset tokens
 cache
  cache:clear         Flush the application cache
  cache:forget        Remove an item from the cache
  cache:table         Create a migration for the cache database table
 db
  db:seed             Seed the database with records
 make
  make:migration      Create a new migration file
  make:seeder         Create a new seeder class
 migrate
  migrate:fresh       Drop all tables and re-run all migrations
  migrate:install     Create the migration repository
  migrate:refresh     Reset and re-run all migrations
  migrate:reset       Rollback all database migrations
  migrate:rollback    Rollback the last database migration
  migrate:status      Show the status of each migration
 queue
  queue:failed        List all of the failed queue jobs
  queue:failed-table  Create a migration for the failed queue jobs database table
  queue:flush         Flush all of the failed queue jobs
  queue:forget        Delete a failed queue job
  queue:listen        Listen to a given queue
  queue:restart       Restart queue worker daemons after their current job
  queue:retry         Retry a failed queue job
  queue:table         Create a migration for the queue jobs database table
  queue:work          Start processing jobs on the queue as a daemon
 schedule
  schedule:finish     Handle the completion of a scheduled command
  schedule:run        Run the scheduled commands

ref:
https://laravel-china.org/docs/lumen/5.6/install/1924

带参数的路由和laravel不一样了。注意这里的变化

$router->get('user/{id}', function ($id) {
    return 'User '.$id;
});
$router->get('posts/{postId}/comments/{commentId}', function ($postId, $commentId) {
    //
});
$router->get('user/{id}', function ($id) {
    return 'User '.$id;
});

路由组
中间件

$router->group(['middleware' => 'auth'], function () use ($router) {
    $router->get('/', function ()    {
        // 使用 Auth 中间件
    });

    $router->get('user/profile', function () {
        // 使用 Auth 中间件
    });
});

命名空间
指定相同的 PHP 命名空间给控制器群组。可以使用 namespace 参数来指定群组内所有控制器的命名空间:

$router->group(['namespace' => 'Admin'], function() use ($router)
{
    // 使用 "App\Http\Controllers\Admin" 命名空间...

    $router->group(['namespace' => 'User'], function() use ($router) {
        // 使用 "App\Http\Controllers\Admin\User" 命名空间...
    });
});

路由前缀
通过路由群组数组属性中的 prefix,在路由群组内为每个路由指定的 URI 加上前缀。例如,你可能想要在路由群组中将所有的路由 URI 加上前缀 admin:

$router->group(['prefix' => 'admin'], function () use ($router) {
    $router->get('users', function ()    {
        // 匹配 "/admin/users" URL
    });
});





















©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 原文链接 必备品 文档:Documentation API:API Reference 视频:Laracasts ...
    layjoy阅读 12,735评论 0 121
  • 前言   老实说,第一次老大让我看laravel框架手册的那天早上,我是很绝望的,因为真的没接触过,对我这种渣渣来...
    mworld阅读 2,271评论 0 0
  • 0.1配置1.模板继承2.控制器3.git4.支付宝支付的流程5.路由6.中间件7.请求8.laravel 学习笔...
    云龙789阅读 4,282评论 0 5
  • Laravel框架一:原理机制篇 Laravel作为在国内国外都颇为流行的PHP框架,风格优雅,其拥有自己的一些特...
    Mr_Z_Heng阅读 9,259评论 0 13
  • 《金陵十二钗》的创作缘起 小时候喜欢读《红楼梦》的原因很单纯,就是觉得它美。特别是那些集美貌与才华于一身但又个性迥...
    卓华艺境阅读 4,583评论 3 12

友情链接更多精彩内容