InterNACHI / modular

Modularize your Laravel application
MIT License
772 stars 64 forks source link

`DIRECTORY_SEPARATOR` issue with Modular running in Windows #40

Closed Sophist-UK closed 2 years ago

Sophist-UK commented 2 years ago
InterNACHI\Modular\Exceptions\CannotFindModuleForPathException
Unable to determine module for 'C:\Laravel\app-modules/Developer/resources'

As you can see the $path contains a mixture of \ and /. I believe that this then triggers an issue in the extractModuleNameFromPath function in Support/ModuleRegistry.php.

In essence developers of PHP code have a choice - they can either:

  1. Ensure that all paths use the DIRECTORY_SEPARATOR every time; or
  2. Work on the basis of using / all the time (which generally are converted by PHP to \ on Windows) and just make sure to replace \ with / whenever you get a real path given by the user or by PHP. A little internet research suggests that this is preferred / recommended because URLs use /.

It appears that in InterNachi Modular we have a mixed usage.

Sophist-UK commented 2 years ago

P.S. I should add that this is a new Laravel project. I installed Laravel and Modular and debugbar and created a couple of modules and went to test that the Laravel welcome page still displayed and got this error.

inxilpro commented 2 years ago

@Sophist-UK can you try the dev-main release and confirm that your PR has resolved the Windows path issues?

Sophist-UK commented 2 years ago

I can test this as soon as my laptop is back running (awaiting new power brick).

Sophist-UK commented 2 years ago

I have just tested this and can confirm that it fixed the issue I was having above.

Sophist-UK commented 2 years ago

Fixed by #38