samedi 1 février 2020

Laravel - Executing command in controller, track progress

I have a system where the user can download a composer package with the click of a button. The installation goes fine and the package gets installed but there is no way to track the progress of the command. I want to track the progress and show it in a progress bar but I don't quite know how to?

Links

<a href="" class="badge badge-light fa-1x">Install</a>
<div class="progress">
    <div class="progress-bar" role="progressbar" aria-valuenow="75" aria-valuemin="0" aria-valuemax="100"></div>
</div>

<a href="" class="badge badge-light fa-1x">Uninstall</a>

Routes

Route::get('package/install', 'PackageController@install')->name('install_package');
Route::get('package/uninstall', 'PackageController@uninstall')->name('uninstall_package');

Controller

public function install()
    {
        $package = new Process("composer require rainieren/visitors");
        $package->setWorkingDirectory(base_path());
        $package->run();

        return redirect('/');
    }

    public function uninstall()
    {
        $package = new Process("composer remove rainieren/visitors");
        $package->setWorkingDirectory(base_path());
        $package->run();

        return redirect('/');
    }

Can this be done? Thanks in advance!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire