laravel-zero/laravel-zero

Composer Warnings when installing pest-plugin-laravel

eleftrik opened this issue · 3 comments

Bran new Laravel Zero app.
I try to add pest-plugin-laravel:

composer create-project --prefer-dist laravel-zero/laravel-zero movie-cli
cd movie-cli
composer require --dev pestphp/pest-plugin-laravel

I got a lot of messages like this:

Warning: Ambiguous class resolution, "Illuminate\Foundation\Application" was found in both "/private/tmp/movie-cli/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Application.php" and "/private/tmp/movie-cli/vendor/laravel/framework/src/Illuminate/Foundation/Application.php", the first will be used.

Warning: Ambiguous class resolution, "Illuminate\Foundation\Vite" was found in both "/private/tmp/movie-cli/vendor/laravel-zero/foundation/src/Illuminate/Foundation/Vite.php" and "/private/tmp/movie-cli/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php", the first will be used.

...

I got same warnings on each composer dump-autoload.

Despite these warnings, I can use the plugin (for example, artisan helper inside a test is working).

Is there a way to avoid these warnings? Am I doing anything wrong?

Thank you!

@eleftrik I came across the same warning and adding the Laravel framework lib to the exclude-from-classmap suppressed the warnings for me.

"autoload": {
    "exclude-from-classmap": [
        "vendor/laravel/framework/src/Illuminate/"
    ],
    "psr-4": {
        "App\\": "app/",
        "Database\\Factories\\": "database/factories/",
        "Database\\Seeders\\": "database/seeders/"
    }
},

I installed spatie/laravel-queueable-action which also requires the Laravel Illuminate library, but Zero already installs a mirrored Illuminate library. The warning is that they're both using the same namespaces and Composer complains about it when generating the autoloader.

Ideally it would be best to not install the duplicate library at all, but I'm not sure if that is possible from the Composer file?

Although, are you sure you need the Laravel plugins package? Just out of curiosity, what does that plugin lib have that Zero doesn't already come pre-packaged?

Yeah, this happens because it installs laravel/framework, which laravel-zero/framework conflicts with.

I don't think there's actually much reason to add the Laravel plugin for Pest within a Laravel Zero application. I think either we need a separate Laravel Zero Pest plugin, or you'll need to develop without the helper functions that plugin provides (which really isn't that much).

@owenvoke I need the Laravel plugin because I'm used to its helpers. Of course, I can live without it, but it's a comfort :)
Anyway, I was wondering how such conflict situations are resolved (if there is a solution or not).
Thanks