2

I'm trying to back up the system using an HTTP request(using a button). I've configured my codebase according to the laravel spatie documentation. When I tried to run the command php artisan backup:run in the terminal it executes just fine and gives a backup file(.zip)

But when I tried to run the command using a controller it gives,

Symfony\Component\Console\Exception\CommandNotFoundException
The command "backup:run" does not exist.

Here's my controller,

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Artisan;

class BackupController extends Controller
{
    public function index() {
        $artisan = \Artisan::call('backup:run');
        $output = \Artisan::output();
        ...
    }
}

and here's my route,

Route::middleware(['auth:sanctum', 'verified'])
    ->get('/backup', [BackupController::class, 'index'])
    ->name('backup');

I've tried to solve the problem by adding Spatie\Backup\BackupServiceProvider::class, to app.php, clearing cache and also tried to redo the whole process from the beginning. But unfortunately, the same error appears.

Hoping for some help to solve the issue, thanks in advance.

Avishka Dambawinna
  • 1,180
  • 1
  • 13
  • 29

0 Answers0