nWidart / laravel-modules

Module Management In Laravel

Home Page:https://docs.laravelmodules.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Composer task

enterprime opened this issue · comments

Hi,

Maybe someone has an idea on how to solve such a task. (I have the merge-plugin section specified accordingly).

I have created a module that installs other modules from the interface (downloads and unpacks the archive).

When the module is activated, an error occurs:
Class "Modules\Test1\Providers\Test1ServiceProvider" not found

if you execute composer dump-autoload, the error disappears
how can we bypass composer?

there was no such problem in version 10.

You can try run the command like this:

$process = new Process(['composer', 'dump-autoload']);
$process->run();

if (! $process->isSuccessful()) {
    throw new RuntimeException($process->getErrorOutput());
}

echo $process->getOutput();

The Process class is used to run the composer dump-autoload command. If the command fails, it throws an exception with the error output. If the command is successful, it prints the output to the console.

Thank you for the hint! In this variant, it looks for Composer in the public folder (my Apache configuration is set up this way).

I used the following code, and everything worked out:

use Illuminate\Support\Facades\Process;

Process::path(base_path())
        ->command('composer dump-autoload')
        ->run()->output()

Thank you.