Artisan Console命令行

Artisan 是 Laravel 自带的命令行接口名称,它为我们在开发过程中提供了很多有用的命令。想要查看所有可用的Artisan命令,可使用list命令:

php artisan list

每个命令都可以用help指令显示命令描述及命令参数和选项。想要查看帮助界面,只需要在命令前加上help就可以了:

php artisan help migrate

用法:(需要在项目根目录使用)

command [options] [arguments]

option可选值:

 -h, --help            Display this help message(用于显示关于命令的更多信息,如:php artisan help migrate)

 -q, --quiet           Do not output any message(不输出任何消息,

  -V, --version         Display this application version(显示laravel版本)

      --ansi            Force ANSI output(用ANSI码输出)

      --no-ansi         Disable ANSI output(禁用ANSI码输出)

  -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(增加冗长的消息:1 正常输出 2 更加详细的输出 3调试输出)


可用的命令(commands):

  clear-compiled       Remove the compiled class file(清除编译过的文件)
  down                 Put the application into maintenance mode(进入应用编程维护模式)
  env                  Display the current framework environment(显示当前框架环境)
  help                 Displays help for a command
  inspire              Display an inspiring quote(显示产生的引用)
  list                 Lists commands
  migrate              Run the database migrations(数据库迁移,当产生了迁移文件后可以进行加载到数据库)
  optimize             Optimize the framework for better performance(优化框架获取更好的性能)
  serve                Serve the application on the PHP development server(开发服务器中该应用的服务)
  tinker               Interact with your application(和应用进行交互)
  up                   Bring the application out of maintenance mode(脱离维护模式)

app

  app:name             Set the application namespace(设置应用的命名空间)

 

auth

  auth:clear-resets    Flush expired password reset tokens(清楚过期的密码并且清除tokens)

 

cache

  cache:clear          Flush the application cache(清楚缓存)

  cache:table          Create a migration for the cache database table(创建缓存数据库表的迁移文件)

 

config

  config:cache         Create a cache file for faster configuration loading(创建缓存的配置文件以达到更快的加载)

  config:clear         Remove the configuration cache file(移除缓存的配置文件)

 

db

  db:seed              Seed the database with records(发送数据记录的)


event

  event:generate       Generate the missing events and listeners based on registration(生成错过的事件和基于注册的监听者)

 

key

  key:generate         Set the application key(产生application key)



 make

  make:auth            Scaffold basic login and registration views and routes(搭建基本的登录和注册view和路由)

  make:command         Create a new Artisan command(创建一个新的命令)

  make:controller      Create a new controller class(创建新的controller类,生成的控制器位于app/Http/Controllers目录

  make:event           Create a new event class(创建新的事件类,如:php artisan make:event taskEvent,生成位于/app/Events/taskEvent.php

  make:job             Create a new job class(创建新的工作类,如:php artisan make:job taskJob,生成位于/app/Jobs/taskJob.php

  make:listener        Create a new event listener class(创建事件监听者类,如:php artisan make:listener --event=taskEVENT(指定需要监听的事件) taskListener,生成位于app/Listeners/taskListener.php

  make:mail            Create a new email class(创建email类,如php artisan make:mail taskEmail,
生成位于app/Mail/taskEmail.php

  make:middleware      Create a new middleware class(创建中间件类,如:php artisan make:middleware taskmw,生成位app/Http/Middleware/taskmw.php

  make:migration       Create a new migration file(创建一份迁移文件,如php artisan make:migration create_tasks_table --create=tasks

生成的新迁移文件位于database/migrations目录下。你可能已经注意到了,make:migration命令已经在迁移文件中添加了自增ID和时间戳。

  make:model           Create a new Eloquent model class(创建Eloquent模型类,php artisan make:model Task该模型位于应用的app目录下,默认情况下,该模型类是空的。我们不需要明确告诉Eloquent模型对应哪张表,Laravel底层会有一个映射规则,这一点在Eloquent文档已有说明,按照规则,这里Task模型默认对应tasks表。

  make:notification    Create a new notification class(创建通告类)

  make:policy          Create a new policy class(创建政策类,

Laravel使用“策略”来将授权逻辑组织到单个类中,通常,每个策略都对应一个模型,因此,让我们使用Artisan命令创建一个TaskPolicy,生成的文件位于app/Policies/TaskPolicy.phpphp artisan make:policy TaskPolicy

  make:provider        Create a new service provider class(创建服务提供者类)

  make:request         Create a new form request class(创建form请求类)

  make:seeder          Create a new seeder class(创建播放者类)

  make:test            Create a new test class(创建test类)



 migrate

  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(显示各个迁移的状况)

 

notifications

  notifications:table  Create a migration for the notifications table(创建关于通知的迁移)

 

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(在队列中创建一个作为守护进程的进程)


 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(罗列已注册的路由)

 

schedule

  schedule:run         Run the scheduled commands(运行已经计划的命令)


 session

  session:table        Create a migration for the session database table(创建关于session数据库表的迁移文件


 storage

  storage:link         Create a symbolic link from "public/storage" to "storage/app/public"(创建软链接从"public/storage" 到"storage/app/public"

 

vendor

  vendor:publish       Publish any publishable assets from vendor packages(发布关于vendor包的任何公开的资源

 

view

  view:clear           Clear all compiled view files(清楚所有的已编译的视图文件,在/storage/framework/views)




参考文章:

http://laravelacademy.org/post/3297.html

http://www.golaravel.com/post/laravel-5-0-artisan-cli-options-list/


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值