Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composer Warnings when installing pest-plugin-laravel #481

Open
eleftrik opened this issue Jan 14, 2024 · 3 comments
Open

Composer Warnings when installing pest-plugin-laravel #481

eleftrik opened this issue Jan 14, 2024 · 3 comments

Comments

@eleftrik
Copy link

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!

@apepindev
Copy link

@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?

@owenvoke
Copy link
Member

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).

@eleftrik
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants