PHP artisan 命令合集

创建控制器

php artisan make:controller 控制器名称
php artisan make:controller SitesController

创建模型 model

php artisan make:model 模型名称
php artisan make:model User

创建数据表

php artisan make:migration create_表名_table --create=表名

php artisan make:migration create_tasks_table --create=tasks // 创建 migration 文件
php artisan migrate //执行创建指令

添加数据表字段名

php artisan make:migration add_字段名_column_to_表名 --table=表名

php artisan make:migration add_intro_column_to_tasks --table=tasks
php artisan migrate
本作品采用《CC 协议》,转载必须注明作者和本文链接
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 17

@dope2008 这个也就是个人的学习笔记,专栏描述那里有说明!让您见笑了!不过,这篇是需要随着学习的深入,不断完善的!

6年前 评论
gitxuzan

来个集合啊,我都点赞了

6年前 评论
gitxuzan

来个集合

6年前 评论

使用php artisan list,列出所有的artisan 命令;

Available 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
 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
 handler
  handler:command     Create a new command handler class
  handler:event       Create a new event handler class
 key
  key:generate        Set the application key
 make
  make:command        Create a new command class
  make:console        Create a new Artisan command
  make:controller     Create a new resource controller class
  make:event          Create a new event class
  make:job            Create a new job class
  make:listener       Create a new event listener class
  make:middleware     Create a new middleware class
  make:migration      Create a new migration file
  make:model          Create a new Eloquent model class
  make:policy         Create a new policy class
  make:provider       Create a new service provider class
  make:request        Create a new form request class
  make:seeder         Create a new seeder class
  make:test           Create a new test class
 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
 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:subscribe     Subscribe a URL to an Iron.io push queue
  queue:table         Create a migration for the queue jobs database table
  queue:work          Process the next job on a queue
 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
 vendor
  vendor:publish      Publish any publishable assets from vendor packages
 view
  view:clear          Clear all compiled view files
6年前 评论

使用 $ php artisan help 命令列出命令使用方法,例如:
$ php artisan help make:migration

Usage:
  make:migration [options] [--] <name>

Arguments:
  name                   The name of the migration.

Options:
      --create[=CREATE]  The table to be created.
      --table[=TABLE]    The table to migrate.
      --path[=PATH]      The location where the migration file should be created.
  -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

Help:
  Create a new migration file
6年前 评论

@赵亚博 谢谢指点!我这个只是个人的学习笔记,只是为了自己在学习过程中,学完后的总结和巩固!
我真不应该发出来!哎……

6年前 评论

我还是换个地方做笔记吧!?

6年前 评论

@Nixus 任何东西都是从无到有的过程,用到的时候一点点的往这个学习笔记里面更新就好了,总会成为合集的。:+1:

6年前 评论

@赵亚博 是的。本来就是想,把学到的 php artisan 命令都记在这里

6年前 评论
DukeAnn

标题的锅

6年前 评论

这尼玛太少了吧,这叫合集,合毛线啊

6年前 评论

真萌,什么文章都有,哎。

6年前 评论

@赵亚博 算你厉害.这下全了.不过谁翻译成中文,估计更多人喜欢

6年前 评论

值得鼓励:+1:

6年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!