Rate this article :
This article was useful to you ?
Yes
No
Vous avez noté 0 étoile(s)
Sommaire
Procédure
php artisan is the command line interface included with Laravel. It provides many useful commands for developing and managing a Laravel application. Here is a guide to some of the most common artisan commands and how to use them.
Before reading this documentation, we invite you to access your hosting's Web Terminal.
To see all the commands available in Laravel :
php artisan list
To start the integrated development server :
php artisan serve
Starts a local development server to run your Laravel application.
By default, the server starts on http://localhost:8000. You can specify a different port:
php artisan serve --port=8080
Migrations are used to manage the database structure.
Creating a new migration:
php artisan make:migration create_users_tableCreates a new migration file for the database.Run migrations:
php artisan migrateExecutes the database migrations and updates the database schema.
Undo the last migration:
php artisan migrate:rollback
	Templates are used to interact with the database tables.
Create a new model:
php artisan make:model User
	Create a model with a migration, a controller and a factory:
php artisan make:model User -mcr
	Controllers manage the logic of the application.
Create a new controller:
php artisan make:controller UserController
	Create a resource controller:
php artisan make:controller UserController --resource
	Views manage the presentation of the application.
artisan command for creating views. You simply create a new file in the resources/views directory.The seeder is used to populate the database with test data.
Create a seeder:
php artisan make:seeder UsersTableSeeder
	Run the seeder:
php artisan db:seed
	Run a specific seeder:
php artisan db:seed --class=UsersTableSeeder
	Laravel uses different types of cache to improve performance.
Empty the application cache:
php artisan cache:clear
	Empty the configuration cache:
php artisan config:clear
	Clear the route cache:
php artisan route:clear
	Generating a cache file for routes and improving performance
php artisan route:cache
	
Clearingthe cache for compiled views:
php artisan view:clear
	
php artisan tinker
Launches Laravel's interactive console for testing code and interacting with your application.
php artisan storage:link
This command creates a symbolic link named storage in your project's public directory.
Here is an example of a typical workflow using php artisan:
Create a new model with a migration and a controller:
php artisan make:model Product -mcr
	Write the migration in database/migrations/YYYY_MM_DD_create_products_table.php and add the necessary fields.
Run the migration:
php artisan migrate
	Create a new route in routes/web.php:
Route::resource('products', ProductController::class);
	Start the development server:
php artisan serve
	Access the application via the browser and interact with the products via the routes generated automatically by the resource controller.
php artisan is a powerful and versatile tool that simplifies many common tasks in Laravel development. It allows you to manage the database, generate code, start a development server and much more, making the development of Laravel applications more efficient and organised.
Composer documentation: https: //laravel.com/docs/11.x/artisan
You now know how to :
php artisan list command to display all the commands available in Laravel.php artisan serve and even specify a different port.artisan commands.By following these steps, you'll become a true php artisan maestro, able to orchestrate the development of your Laravel applications with ease and efficiency 🎼👨💻.
Thank you for following us so far! If you have any questions or feedback on using these commands, don't hesitate to leave a comment below. Your experience enriches our community. See you soon for more exciting developments with Laravel! 😊🚀
Rate this article :
This article was useful to you ?
Yes
No
1mn reading
How do I connect to the Web Terminal with LWS Panel? (ssh web console)
4mn reading
How can I use GIT with the Web terminal on my LWS shared hosting?
2mn reading
How to change the PHP version of the LWS Panel Web Terminal
0mn reading
What can I do on my WordPress site using the Web Terminal?