Linux command
artisan 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
List all available commands
php artisan list
Start the development server
php artisan serve
Run database migrations
php artisan migrate
Create a new controller
php artisan make:controller [UserController]
Create a new model
php artisan make:model [Post] --migration
Generate application key
php artisan key:generate
Clear all caches
php artisan optimize:clear
Open interactive shell
php artisan tinker
说明
Artisan is Laravel's command-line interface for PHP web application development. It provides commands for common tasks like database migrations, code generation, cache management, and queue processing. The tool automates repetitive development tasks through its make: commands, which generate boilerplate code for controllers, models, migrations, tests, and other Laravel components. Database management is handled through migration commands that version-control schema changes. Tinker provides an interactive REPL (Read-Eval-Print Loop) for exploring the application, testing code snippets, and interacting with Eloquent models directly. Custom commands can be created with make:command and registered automatically from the app/Console/Commands directory. Commands support arguments, options, user prompts, and formatted output including tables and progress bars.
参数
- list
- Display all available commands
- serve
- Start the built-in development server
- migrate
- Run database migrations
- migrate:rollback
- Rollback the last database migration
- db:seed
- Run database seeders
- make:controller _name_
- Create a new controller class
- make:model _name_
- Create a new Eloquent model
- make:migration _name_
- Create a new migration file
- make:command _name_
- Create a new Artisan command
- cache:clear
- Clear the application cache
- config:cache
- Cache the configuration files
- route:list
- List all registered routes
- queue:work
- Process jobs from the queue
- tinker
- Open an interactive REPL shell
- key:generate
- Generate application encryption key
- optimize
- Cache configuration, routes, and views
- optimize:clear
- Clear all cached files
- --help
- Display help for a command
- -v, -vv, -vvv
- Increase verbosity of output
- --env=_environment_
- Run command in a specific environment
FAQ
What is the artisan command used for?
Artisan is Laravel's command-line interface for PHP web application development. It provides commands for common tasks like database migrations, code generation, cache management, and queue processing. The tool automates repetitive development tasks through its make: commands, which generate boilerplate code for controllers, models, migrations, tests, and other Laravel components. Database management is handled through migration commands that version-control schema changes. Tinker provides an interactive REPL (Read-Eval-Print Loop) for exploring the application, testing code snippets, and interacting with Eloquent models directly. Custom commands can be created with make:command and registered automatically from the app/Console/Commands directory. Commands support arguments, options, user prompts, and formatted output including tables and progress bars.
How do I run a basic artisan example?
Run `php artisan list` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does list do in artisan?
Display all available commands