For the past two weeks, my team and I have been grappling with an issue stemming from the upgrade to Laravel version 10 and Laravel-modules version 10. Initially, we encountered difficulties locating modules, resulting in numerous "routes not found" errors within our module ecosystem. Subsequently, we began experiencing issues with Livewire components not being found. Our application functions smoothly on local machines, but once we mount the volume to a Docker image container, errors such as "Unable to find component: [blog::index]" arise.
Upon attempting to create a Livewire component using the laravel-modules-livewire package within the Docker container, we encountered a peculiar scenario. While the view files were found to already exist, the associated class was missing. Upon re-executing the artisan command to create the component, both the view and class were reported to exist. Further investigation revealed the creation of a new folder labelled "App/" alongside the existing "app/" directory - a case-sensitive path, caused by namespace.
The root cause of this issue lies in the configuration of the Laravel module Livewire package, which utilizes the namespace "App/Livewire". However, due to the mismatch between the existing "app/Livewire" path and the "App/Livewire" namespace, the system throws errors indicating that the component is not found.
Solution:
Update Namespace: One solution involves modifying the namespace to remove the "app/" fragment, resulting in a namespace structure like "Blog/Livewire", instead of "Blog/App/Livewire". While this provides a quick fix, it is not a sustainable solution and may lead to recurring issues in the future.
Include "app/" in Namespace (Lowercase): Another approach entails retaining the "app/" fragment in the namespace but converting it to lowercase. However, this practice is suboptimal and was previously utilized in the laravel-modules package until version 11, which opted for the first solution mentioned above.
Utilize composer-merge-plugin: The most appropriate solution involves mapping the "app/" path to "App/" using the wikimedia/composer-merge-plugin package. This approach ensures compatibility and adherence to naming conventions across different environments.
Additional Notes:
It's crucial to recognize that Linux is case-sensitive, unlike Windows and macOS, which exacerbates the namespace discrepancy issue.
While a previous attempt to address this issue through a pull request was met with concerns regarding the extent of changes, I am eager to submit a new pull request to resolve this matter comprehensively.
By sharing my experience with the community, I hope to guide others who may encounter similar challenges.
@dcblogdev
Your attention to this matter is greatly appreciated.
Description:
For the past two weeks, my team and I have been grappling with an issue stemming from the upgrade to Laravel version 10 and Laravel-modules version 10. Initially, we encountered difficulties locating modules, resulting in numerous "routes not found" errors within our module ecosystem. Subsequently, we began experiencing issues with Livewire components not being found. Our application functions smoothly on local machines, but once we mount the volume to a Docker image container, errors such as "Unable to find component: [blog::index]" arise.
Upon attempting to create a Livewire component using the laravel-modules-livewire package within the Docker container, we encountered a peculiar scenario. While the view files were found to already exist, the associated class was missing. Upon re-executing the artisan command to create the component, both the view and class were reported to exist. Further investigation revealed the creation of a new folder labelled "App/" alongside the existing "app/" directory - a case-sensitive path, caused by namespace.
The root cause of this issue lies in the configuration of the Laravel module Livewire package, which utilizes the namespace "App/Livewire". However, due to the mismatch between the existing "app/Livewire" path and the "App/Livewire" namespace, the system throws errors indicating that the component is not found.
Solution:
wikimedia/composer-merge-plugin
package. This approach ensures compatibility and adherence to naming conventions across different environments.Additional Notes:
@dcblogdev Your attention to this matter is greatly appreciated.
Thank you.
Issue on laravel-modules:
https://github.com/nWidart/laravel-modules/issues/1819
Ref:
https://github.com/nWidart/laravel-modules/pull/1758
42