savannabits / filament-modules

Integration of Filament with nWidart/laravel-modules: Create independent Filament Files for each Laravel Module
https://filamentphp.com/plugins/coolsam-modules
MIT License
109 stars 22 forks source link

[Bug]: #92

Closed Mike-Hawwke closed 6 months ago

Mike-Hawwke commented 6 months ago

What happened?

Hello,

I have installed your plugin in my Filament v3 (Laravel 11) installation. When I do -> php artisan module:make:filament-resource (Document) and I generate the resource, I get an error that appears:

Class "Modules/Document/Providers/DocumentServiceProvider" not found

If I move the provider folder to the root of the plugin folder, it works.

But the new resource does not appear in the Filament menus after generating the model and migration.

thx

How to reproduce the bug

Basic installation with latest version of laravel and module follow the installation steps

Package Version

v4.x

PHP Version

8.2

Laravel Version

11

Which operating systems does with happen with?

No response

Notes

No response

coolsam726 commented 6 months ago

That's strange, kindly show me the exact command that you ran and you modules structure. Also, let me know if you published the module's configs or not, for ease of reproduction.

Mike-Hawwke commented 6 months ago

the command composer require coolsam/modules php artisan vendor:publish --tag="modules-config" php artisan module:make Document php artisan module:filament:install Document php artisan module:make:filament-resource name model Document

I only have this module at the moment and I stopped at the step where I generate my resource

I am attaching a screen of the config file of your plugin and the error

2024-04-19 140300 2024-04-19 140101

coolsam726 commented 6 months ago

I see. Just curious, did you go through the following process? image This module depends on nwidart/laravel-modules being configured and working properly. If you didn't go through its documentation, you might have missed a step which ensures modules are auto-discovered by the parent app. I am specifically suspecting this part of the documetation: image

Mike-Hawwke commented 6 months ago

the extra is in the composer.json (see screen)

2024-04-19 144156

coolsam726 commented 6 months ago

I am afraid I cannot reproduce the error, I even created an app from scratch just to try and reproduce, but it is working fine. image However, I noticed from your screenshot that you are using windows. I don't have a windows machine and I always develop on Linux, so it is possible that this bug occurs on Windows. Can someone else confirm this?

Mike-Hawwke commented 6 months ago

Can you give me access to this project to see the differences between yours and mine?

coolsam726 commented 6 months ago

I didn't push it to a repo yet. However, I wrote a test to check the convertPathToNamespace method which seems to be the cause of your failure, and the test is passing on linux but failing on windows, so I can almost certainly confirm that this is a bug with the function on the windows platform. image Let me attempt a fix and update you.

coolsam726 commented 6 months ago

All Tests now give a good indicator. Please try v4.0.3 and report if it fixes your issue. This is a windows directory separator related issue.

Mike-Hawwke commented 6 months ago

Thank you for your intervention

After udpate of the module I carried out the commands

php artisan module:make Document I first had an error at the same step but it was different and referred to a problem with Nwidart

I did some research and came across this https://github.com/nWidart/laravel-modules/issues/4

So I applied the modification to config/models.php in the generator

The error disappeared so I performed the second command

php artisan module:filament:install Document

A second error has occurred https://flareapp.io/share/x7XaAzY5

I will share my progress with you if I find the reason

Mike-Hawwke commented 6 months ago

When trying to create the resource I got this error (see screen) 2024-04-19 180329

I wonder while searching there I came across getModulePlugins

This one also contains a path, possible that the problem is linked to Windows as above?

coolsam726 commented 6 months ago

When trying to create the resource I got this error (see screen) 2024-04-19 180329

I wonder while searching there I came across getModulePlugins

This one also contains a path, possible that the problem is linked to Windows as above?

It is definitely a bug only with windows, my methods are mixing up DIRECTORY SEPARATORS. I think I will have to setup a dev environment on Windows so that I can re-test the entire package to ensure each command works on windows.

thexaib commented 6 months ago

I am getting same error on MacOS 14.3.1 for filament-modules:4.0.3 , when plugins are registered by ModulesPlugin::make() , it throws error. My module from nWidart/laravel-modules is working fine if ModulesPlugin::make() is NOT called everything worked when using filament-modules:4.0.2 Error:

 Class "Modules\Consents\app\Filament\ConsentsPlugin" not found

  at vendor/coolsam/modules/src/ModulesPlugin.php:22
     18▕         $panel
     19▕             ->topNavigation(config('filament-modules.clusters.enabled', false) && config('filament-modules.clusters.use-top-navigation', false));
     20▕         $plugins = $this->getModulePlugins();
     21▕         foreach ($plugins as $modulePlugin) {
  ➜  22▕             $panel->plugin($modulePlugin::make());
     23▕         }
     24▕     }
     25▕ 
     26▕     public function boot(Panel $panel): void

      +2 vendor frames 

  3   app/Providers/Filament/SupervisorPanelProvider.php:81
      Filament\Panel::plugins()
      +35 vendor frames 

  39  [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Filament\FilamentServiceProvider))
coolsam726 commented 6 months ago

Please try v4.0.4 and confirm to me that it fixes the issue. Thanks.

thexaib commented 6 months ago

Working Now. Thanks

coolsam726 commented 6 months ago

Thanks for the feedback @thexaib. If you experience any other issues, don't hesitate to post them.

Mike-Hawwke commented 6 months ago

Hi @coolsam726 ,

I still have problems with your code

For reasons of simplicity I took a server directly and did the installation on it But I still end up with the same kind of error

I don't understand where the problem comes from

2024-04-22 122207 2024-04-22 122242

Thank you for your help

Mike-Hawwke commented 6 months ago

I can't solve the problem, can you help me @coolsam726 ?

Here's where I'm stuck

I am now on server When I do the installation no problem I create my module but when I want to install it I get this error that appears 2024-04-22 163017

coolsam726 commented 6 months ago

@Mike-Hawwke Do you mind sharing a public repo of your code so that I can reproduce the error and try to help?

coolsam726 commented 6 months ago

Closing for now till I hear back from you.