PHP Artisan: Artisan is a command-line UI that can aid you while you build your application. PHP artisan command performs multiple tasks in less time and is more efficient. It can be used to create a model, to create a cache, to create a controller, and can also be used to create Laravel packages and add dummy data too.
PHP artisan serve: This command can be used to run your application. It is used for developing and testing purposes as well.
- By default, it takes hostname as the localhost.
php artisan serve
- If you want to change the hostname as well as the port number, you can use the following command.
php artisan serve --host=hostname.app --port=8080
Usage of PHP artisan command: The important thing you need to know while using Laravel is, running your project through localhost is not possible, it can be run only through the php artisan serve command itself.
- Create the model: This command will generate the model username.php into the pre-existing Models folder or if the folder does not exist it will create one. You can find the model in this location app/Models/modelname.php
php artisan make:model
- Clear cache: When more users register for your website it might cause the authentication system to fail, the cache in the laravel can be cleared by using these commands. You can also remove all cache files and session files from storage manually as well.
- To flush the application cache
php artisan cache:clear
- To remove configuration cache file
php artisan config:clear
- To clear all the compiled view files
php artisan view:clear
- To flush the application cache
- Create Controller: The following command is used to create the controller.
Generates TestController inside the Controller folder
php artisan make:controller TestController
PHP artisan dump-autoload: The php artisan dump-autoload command call the Composer with optimize flag. It will recompile loads of files creating the huge bootstrap/compiled.php
PHP Composer The composer is an application-level package manager for PHP Programming language. A composer is a tool for managing the dependencies in PHP. There are several commands which you need to know before using the composer tool.
- Composer.json: To begin using composer all you need is a composer.json file. This file includes all the dependencies of your created project and the metadata as well.
- Composer install: The
composer installcommand can be used to add on the dependencies. This command will not update anything. You need to add it manually to the composer.json file whereas if composer.lock already exists install exactly what is specified on this file otherwise read composer.json file to make it easier.
- Composer update: The composer update command can be used to install as well as update the dependencies. This command can be used to add or remove the dependencies but first, add manually to the composer.json file.
- Composer remove: This command can be used to remove unused dependencies. You can uninstall such dependencies using the below command.
composer remove packageauthor/packagename
- Composer dump-autoload: The composer dump-autoload will not download any new thing, all it does is looking for all the classes and files it needs to include again.
Difference Between “PHP artisan dump-autoload” and “PHP composer dump-autoload”: Let us now take a brief look to understand the difference between the composer dump-autoload and PHP artisan dump-autoload commands.
|composer dump-autoload||php artisan dump-autoload|
|It regenerates the list of all the classes that need to be included in the project (autoload_classmap.php).||It will ‘recompile’ loads of files creating the huge bootstrap/compiled.php|
|It wont’t download any new thing to the project.||It will call the composer with optimize flag.|
|Find all the workbench packages and composer dump-autoload them, one by one.||It will use composer for some funtions.|
|This command is supported in all Laravel versions.||This command is deprecated in Laravel 5 and above versions.|
- How to enable PHP's openssl extension to install Composer ?
- Laravel | Artisan Console Introduction
- Laravel | Artisan Commands to know in Laravel
- Difference and Similarities between PHP and C
- Difference between try-catch and if-else statements in PHP
- Difference between isset() and array_key_exists() Function in PHP
- Difference between bindParam and bindValue in PHP
- What is the difference between the | and || or operator in php?
- What is the difference between public, private, and protected in PHP?
- Difference between require-dev and require in PHP?
- What is the difference between HTTP_HOST and SERVER_NAME in PHP?
- What is the difference between is_a() function and instanceof in PHP?
- What is the difference between echo, print, and print_r in PHP?
- What is the difference between array_merge and array + array in PHP?
- What is the difference between a language construct and a “built-in” function in PHP ?
- Difference between “!==” and “==!” in PHP
- Difference between array() and  in PHP
- What is the difference between single-quoted and double-quoted strings in PHP?
- Difference between break and continue in PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.