0

I make

php artisan make:command BackupDatabaseCommand --command="command:backupdb"

I also registered firmly app\Console\kernel.php

protected $commands = [
    \App\Console\Commands\BackupDatabaseCommand::class,
];

But even if you try to execute the command i get here

The system cannot find the path specified. I want to know how to solve it

10
  • 1
    how are you trying to run your command? Commented Nov 7, 2019 at 7:25
  • Can include class as "App\Console\Commands\BackupDatabaseCommand", Commented Nov 7, 2019 at 7:27
  • There should be no need to register them in app\Console\Kernel.php. Does your command show up when running php artisan? Commented Nov 7, 2019 at 7:30
  • The system cannot find the path specified might refer to PHP not being installed, you trying to execute the command outside of the directory where the artisan file is or your command is trying to access a file that is not found. We need to know which one it is really Commented Nov 7, 2019 at 7:35
  • it should be this \Commands\BackupDatabaseCommand::class, not \App\Console\Commands\BackupDatabaseCommand::class, Commented Nov 7, 2019 at 7:35

2 Answers 2

1

Your path is wrong Since you are already in App\Console directory there is no need to specify App\Console it should be this:

protected $commands = [
    Commands\BackupDatabaseCommand::class,
];

here is the image from my working project

enter image description here

Thanks

Sign up to request clarification or add additional context in comments.

12 Comments

their path is not wrong (its the FQCN) and there is no Commands namespace in the root
This is ever worse, there is not Commands namespace in the root namespace.
@SalmanZafar yes and it creates the commands with namespace App\Console\Commands; not namespace Commands;
your answer will generate the string: 'Commands\BackupDatabaseCommand' not 'App\Console\Commands\BackupDatabaseCommand'
I still don't understand why OPs path was wrong, the only explanation would be if they changed their default namespace from App to something else since they did reference it via \App... to indicate the root namespace
|
0

To Create command

php artisan make:command BackupDatabaseCommand --command=command:backupdb

You can register command as:

protected $commands = [
    'App\Console\Commands\BackupDatabaseCommand'
];

and you can run command using:

php artisan command:backupdb

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.