I'm currently trying to return the list of Artisan commands within my Laravel application. I tried running return var_dump(Artisan::('list'));
with success, but my response was unexpected. It came back as int(0)
or 0
when I took out the var_dump()
function. When I run this same command in my console, it returns the list of artisan commands successfully.
Any thoughts on why this might be happening?
Artisan::call() returns the exit code, just like the command would in the terminal. An exit code of 0 means the command executed successfully.
Artisan::output() can be used to get the last command's output.