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
    });
});





















你可能感兴趣的:(2018-10-18)