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

Laravel Modules and PSR-4 Notices #2008

Closed
freescout-help opened this issue Jan 20, 2025 · 2 comments
Closed

Laravel Modules and PSR-4 Notices #2008

freescout-help opened this issue Jan 20, 2025 · 2 comments
Labels

Comments

@freescout-help
Copy link

freescout-help commented Jan 20, 2025

Versions:

  • laravel-modules Version: 2.7.0
  • Laravel Version: 5.5.40
  • PHP Version: 8.4.2

Description:

When adding Laravel Modules into our project we've added the following line to the composer.json:

        "psr-4": {
            "Modules\\": "Modules/",

Everything worked fine but now with the latest composer version it shows numerous notices when running composer install command, like this:

Class CreateWebhookLogsTable located in ./Modules/ApiWebhooks/Database/Migrations/2020_09_12_170000_create_webhook_logs_table.php does not comply with psr-4 autoloading standard (rule: Modules\ => ./Modules). Skipping.
Class ComposerAutoloaderInite40fb95f05c4b5b511f77e2a3d7c43ca located in ./Modules/ApiWebhooks/vendor/composer/autoload_real.php does not comply with psr-4 autoloading standard (rule: Modules\ => ./Modules). Skipping.
Class Parsedown located in ./Modules/ApiWebhooks/vendor/erusev/parsedown/Parsedown.php does not comply with psr-4 autoloading standard (rule: Modules\ => ./Modules). Skipping.

It happens on "Generating optimized autoload files" step.

If we remove "Modules\\": "Modules/" line from the composer.json we are getting the following error:

In Application.php line 635: Class "Modules\ApiWebhooks\Providers\ApiWebhooksServiceProvider" not found

@freescout-help
Copy link
Author

The only thing that helps for now is to do the following:

  1. Remove or rename "Modules" folder.
  2. Run composer install.
  3. Return "Modules" folder back.

@freescout-help
Copy link
Author

Solution:

"scripts": {
	"pre-update-cmd": [
		"@php -r \"@rename('Modules', 'Modules_');\""
	],
	"pre-install-cmd": [
		"@php -r \"@rename('Modules', 'Modules_');\""
	],
	"post-autoload-dump": [
		"@php -r \"@rename('Modules_', 'Modules');\"",
		"@php artisan package:discover"
	]
},

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

No branches or pull requests

1 participant