PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, April 18, 2022

[FIXED] How check if a Laravel Console Command Exists?

 April 18, 2022     laravel, laravel-artisan     No comments   

Issue

I need to check if a Laravel Console Command exists and if it is in the protected command var to call them.

I need to call them from another Laravel console command. And I want to know if there are something like exists_command('mycommand:foo')

There are any way to achieve this?


Solution

Tested and working.

function command_exists($name)
{
    return array_has(\Artisan::all(), $name);
}

if (command_exists('config:cache')) {
    // success
}


Answered By - Sandeesh
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing