#Artisan Command, simple test

7 messages · Page 1 of 1 (latest)

barren gale
#

I'm trying out artisan commands but nothings seems to work? Anyone an idea what i'm doing wrong. This was my test Route::get('/test', function()
{
Artisan::call('help');
dd(Artisan::output());
});

ember spindle
#

That code works for me. What error do you get?

#

But it's not very common to call artisan commands from application code

barren gale
#

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?

ember spindle
#

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?

barren gale
#

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.');
}

}