A summary of laravel's common commands

01-28-2024

What this article brings to you is a summary of laravel's common commands, which has certain reference value. Friends in need can refer to it and hope to help you. # # Create a project laravel new blog || composer create-project --prefer-dist laravel/laravel blog # # Install components composer install # # Refresh component composer update # # Delete component composer remove chensuilong/toastr composer dump-autoload # # View artisan command php artisan php artisan list # # Start the PHP Web service. php artisan serve # # View a help command php artisan help make:model Php artisan make: modeluser-migration creates a model and creates a new migration. # # View laravel version php artisan --version # # Start the application with the development server built in PHP. php artisan serve # # Generate a random key and automatically update it to the key-value pair of app/config/app.php (this step needs to be done just after installation). php artisan key:generate # # Turn on the Auth user function (migration is required to take effect after turning it on) php artisan make:auth # # Turn on the maintenance mode and turn off the maintenance mode (display 503) php artisan down php artisan up # # Enter the tinker tool php artisan tinker # # List all the routes php artisan route:list # # Generate route cache and remove cached route files. php artisan route:cache php artisan route:clear # # Regenerate the signature php artisan passport:install # # Automatically generate Laravel keys php artisan key:generate ##Auth system php artisan make:auth # # Create a controller php artisan make:controller StudentController # # create a Rest-style resource controller (with index, create, store, edit, update, destroy and show methods). php artisan make:controller PhotoController --resource # # Create a model php artisan make:model Student Php artisan make: model user-migration//Create a model and create a new migration. # # Create a new table migration and modify a table migration. Php artisan make: migration create _ users _ table-create = students//Create the students table. Php artisan make: migration add _ votes _ to _ users _ table-table = students//Add the votes field to the students table. # # Perform migration php artisan migrate Php artisan migrate:rollback // Rollback the latest migration. # # When creating the model, the migration of new tables is generated at the same time. php artisan make:model Student -m # # Rollback the last migration php artisan migrate:rollback # # Rollback all migrations php artisan migrate:reset Php artisan migrate:refresh // update the table structure # # Create a Fill php artisan make:seeder StudentTableSeeder Perform a single population php artisan db:seed --class=StudentTableSeeder # # Perform all padding php artisan db:seed # # Create Middleware (under app/Http/Middleware) php artisan make:middleware Activity # # Create table migration of queue (database) (migration is required to take effect) php artisan queue:table # # Create a queue class (under app/jobs): php artisan make:job SendEmail # # Create a request class (under app/Http/Requests) php artisan make:request CreateArticleRequest

Php artisan: displays detailed command-line help information, the same as php artisan list. Php artisan–help: displays the usage format of the help command, which is the same as php artisan -help. Php artisan -version: displays the current version of Laravel. Php artisan changes: Lists the major changes of the current version compared with the previous version. Php artisan down: set the site to maintenance status. Php artisan up: set the site back to an accessible state. Php artisan optimize: Optimize application performance, generate auto-loading file, and generate aggregate compilation file bootstrap/compiled.php. Php artisan dump-autoload: Regenerates the auto-loading file of the framework, which is equivalent to the reoperation of optimize. Php artisan clear-compiled: Clear the files generated by compilation, which is equivalent to the reverse operation of optimize. Php artisan migrate: perform data migration Php artisan routes: Lists all the routing rules currently applied. Php artisan serve: Use the built-in development server of PHP to start the application [PHP version is required to be 5.4 or above] Php artisan tinker: Enter the REPL environment bound to the current application environment, which is equivalent to the rails console command of the Rails framework. Php artisan workbench Organization Name/Package Name: This will generate a folder named workbench in the application root directory, and then generate a package structure conforming to the Composer standard in the form of organization name/package name, and automatically install the necessary dependencies [you need to improve the contents of the app/config/workbench.php file first]. Php artisan cache:clear: clear the application cache. Php artificial command: make command name: generate a custom command file named command name. PHP in the app/commands directory. Php artisan controller:make controller name: generate a controller file named controller name. PHP in the app/controllers directory. Php artisan db:seed: Fill the database with seed data for testing. Php artisan key:generate: generate a random key and automatically update it to the key-value pair of app/config/app.ph. Php artisan migrate:install: initialize migration data table. Php artisan migrate:make Migration Name: This will generate a data migration file named Time+Migration Name. php in the app/database/migrations directory, and automatically execute the php artisan dump-autoload command once. Php artisan migrate:refresh: reset and re-execute all data migration. Php artisan migrate:reset: roll back all data migration. Php artisan migrate:rollback: Rollback the last data migration. Php artisan session:table: generate a data migration file for session.

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us