#Artisan Command, simple test
7 messages · Page 1 of 1 (latest)
That code works for me. What error do you get?
But it's not very common to call artisan commands from application code
Hi Martin Thanks for the reply, I was trying artisan commands from the basics. I want to use laravel spatie for backups but I keep getting stuck. Can you help me with that?
We can help you if you if you ask questions. If you’re running into issues, show the error.
Im sure “Spatie Backups” have documentation?
If I click on the create backup it shows nothing at the moment ---------- MY CONTROLLER --------------- <?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\Request;
use Spatie\Backup\BackupDestination\BackupDestinationFactory;
use ZipArchive;
use Exception;
class BackupController extends Controller
{
// Show list of backups
public function index()
{
$files = Storage::disk('backups')->files();
return view('backups.index', compact('files'));
}
// Create a new backup
public function create()
{
Artisan::call('backup:run');
return redirect()->route('backups.index')->with('success', 'Backup created successfully.');
}
}