Laravel Artisan Console Commands

Laravel Artisan Console Commands

November 3, 2019

Artisan is the command-line interface included with Laravel. It provides a number of helpful commands that can assist you while you build your application. To view a list of all available Artisan commands , you may use the list command:

Laravel create controller

php artisan make:controller UserController
php artisan make:controller CategoriesController --resource 
php artisan make:controller Blog/PostsController

Laravel create component

php artisan make:component Header
laravel new project_name

php artisan make:auth
php artisan route:list
php artisan migrate:refresh 
php artisan migrate:refresh --seed
php artisan migrate --seed
php artisan ui vue --auth

Model With Migration

php artisan make:model Post -m
php artisan make:model Category -m
php artisan route:clear
php artisan optimize
php artisan up
php artisan down
php artisan config:cache
php artisan migrate:rollback

php artisan migrate --path=/database/migrations/2019_10_06_052849_create_categories_table.php
php artisan help migrate

php artisan make:request CreateCategoryRequest

php artisan make:request Categories/CreateCategoryRequest
php artisan storage:link
php artisan make:migration create_post_tag_table --table=post_tag
php artisan cache:clear

php artisan make:resource CategoriesResource
php artisan make:middleware VerifyCategoriesCount
php artisan make:seeder PostsTableSeeder
php artisan migrate:refresh --seed
php artisan vendor:publish
php artisan make:factory ModelFactory
php artisan make:seed ProductsTableSeeder
php artisan schedule:list
php artisan key:generate

Laravel Tinker

Laravel Tinker allows you to interact with a database without creating the routes. Laravel tinker is used with a php artisan to create the objects or modify the data. Tinker is a command tool that works with a php artisan. A tinker plays around the database means that it allows you to create the objects, insert the data, etc.

php artisan tinker
User::all();
exit

Composer

Composer is an application-level dependency manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries.

composer require laravel/ui
composer update

How to Send Database Notifications

Create a Notifications Table

php artisan notifications:table

Generating Notifications

php artisan make:notification DepositSuccessful

Important artisan commands

Command Description
php artisan list List all available Artisan commands.
php artisan serve
php artisan key:generate
php artisan db:seed –class=PermissionTableSeeder
php artisan db:seed –class=CreateAdminUserSeeder
php artisan db:seed Seed the database with records.
php artisan migrate:rollback –path=database/migrations/2023_08_17_095957_create_mails_table.php
php artisan migrate:rollback will run down() method
php artisan migrate:refresh –seed
php artisan migrate will run up() method
php artisan migrate:fresh
php artisan migrate:reset
php artisan make:migration add_column_to_users_table –table=users
php artisan make:controller ResourcesController –resource
php artisan make:mail OrderShipped
php artisan make:seeder MailSeeder
php artisan make:seeder MailSeeder
php artisan make:component InputLabel
php artisan datatables:make Users
php artisan config:clear
php artisan tinker
php artisan test Run PHPUnit tests.
php artisan test –filter=ArticleTest Run PHPUnit tests. (Single Class)
php artisan make:test ArticleTest Create a new test class.
php artisan config:cache Cache the configuration files.
php artisan config:clear Clear the configuration cache.
php artisan schedule:list List the scheduled tasks.
php artisan route:list List all registered routes.
php artisan route:clear Clear route cache.
php artisan make:model Todo -a create model, controller and migration in single artisan command
php artisan –version Laravel Framework Version