Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Laravel Artisan Custom Commands

Create powerful custom Artisan commands for your application.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Create Command
  2. Command Class
  3. Interactive Input

Custom Artisan commands:

Create Command

php artisan make:command SendEmails

Command Class

php
class SendEmails extends Command
{
    protected $signature = \'emails:send {user} {--queue}\';
    protected $description = 'Send emails to user';

    public function handle()
    {
        $userId = $this->argument('user');
        $queue = $this->option('queue');
        
        $this->info('Sending emails...');
        $this->line('Done!');
    }
}

Interactive Input

php
$name = $this->ask('What is your name?');
$confirmed = $this->confirm('Continue?');
$choice = $this->choice('Select', ['a', 'b']);
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read