---
title: "How to Create Custom Artisan Command in Laravel 8?"
url: "https://magecomp.com/blog/create-custom-artisan-command-laravel-8/"
date: "2022-09-21T17:43:22+00:00"
modified: "2025-01-06T10:29:33+00:00"
author:
  name: "Bharat Desai"
  url: "https://magecomp.com"
categories:
  - "How To"
  - "Laravel"
word_count: 381
reading_time: "2 min read"
summary: "Hello Laravel Developers,"
description: "Artisan provides various commands to build the Laravel application. You can also create your custom Artisan Command in Laravel. Learn more"
keywords: "How To, Laravel"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to cancel order Programmatically without disabling URL security key in Magento 2?"
    url: "https://magecomp.com/blog/cancel-order-programmatically-without-disabling-url-security-key-magento-2/"
  - title: "How to Create Indian GST Tax Rule in Magento 2?"
    url: "https://magecomp.com/blog/create-indian-gst-tax-rule-magento-2/"
  - title: "Top SEO tools to boost your Magento Store Rankings Rapidly"
    url: "https://magecomp.com/blog/top-seo-tools-boost-magento-store-rankings-first/"
---

# How to Create Custom Artisan Command in Laravel 8?

_Published: September 21, 2022_  
_Author: Bharat Desai_  

![How to Create Custom Artisan Command in Laravel 8](https://magecomp.com/blog/wp-content/uploads/2022/09/How-to-Create-Custom-Artisan-Command-in-Laravel-8-1024x512.webp)

**Hello Laravel Developers,**

In this Laravel tutorial, we will learn How to Create Custom Artisan Command in Laravel 8? Before that, let’s understand Artisan in Laravel.
[![Laravel Development Services](https://magecomp.com/blog/wp-content/uploads/2024/12/Laravel-Development-Services-4.webp)](https://magecomp.com/services/laravel-development-services/)

## What is Artisan in Laravel?
Artisan is a command line interface that is included with Laravel. Artisan provides several helpful commands that can assist you in building your application. To view all available Artisan commands, you may use the list command as follows:
```
$ php artisan list
```

This article will show how to create custom artisan commands in Laravel.
Typically commands are stored in the app/console/Commands directory.
Before starting, we need some pre-requirements listed below:
1.  New Laravel project.2.  A secure database connection.3.  And User model.
## How to Create Custom Artisan Command in Laravel:
**Step 1:** First, we will create a command using artisan console or cmd. We need to use the make:command Artisan command. This command will create a new command class in the app/console/commands directory.
```
$ php artisan make:command checkUser
```

**Step 2:** After that, define the appropriate values of $signature and $description properties of the class. The handle method will be called when command is executed. You may place your command logic in this method. Let’s take a look at our checkUser command file.
[![Hire laravel Developer](https://magecomp.com/blog/wp-content/uploads/2024/12/Hire-Laravel-Expert-Now-3.webp)](https://magecomp.com/services/hire-laravel-developer/)

```
<?php

namespace AppConsoleCommands;

use AppModelsUser;
use IlluminateConsoleCommand;

class checkUser extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'check:user {email}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'This command is used to check whether an email address exists in the database or not.';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $email = $this->argument('email');
        $user = User::where('email', $email)->first();
        if ($user)
        {
            $this->info("User is exist");
        }
        else
        {
            $this->info("User not exist");
        }
        return 0;
    }
}
```

Let’s test our command in the console
The below output shows if the user exist

[![user exist](https://magecomp.com/blog/wp-content/uploads/2022/09/user-exist.png)](https://magecomp.com/blog/wp-content/uploads/2022/09/user-exist.png)

The below output shows if the user does not exist

[![user does not exist](https://magecomp.com/blog/wp-content/uploads/2022/09/user-does-not-exist.png)](https://magecomp.com/blog/wp-content/uploads/2022/09/user-does-not-exist.png)

## Conclusion:
This way, you can create any of your required custom Artisan command in Laravel 8. If you have any doubt, let me know through the comment section. Get in touch with our [**Laravel Experts**](https://magecomp.com/hire-laravel-developer.html) to expand your knowledge in Laravel.
[![Contact Us](https://magecomp.com/blog/wp-content/uploads/2024/12/Contact-Us-3.webp)](https://magecomp.com/contact)

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/create-custom-artisan-command-laravel-8/](https://magecomp.com/blog/create-custom-artisan-command-laravel-8/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-14 12:11:48 UTC_  
