diff --git a/README.md b/README.md index 36c85b2..00a4994 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,12 @@ Both filenames and file contents support a number of placeholders. These include - `StubFullyQualifiedTestCaseBase` - `StubTestCaseBase` +#### Modules Path Helper + +The `modules_path` function returns the fully qualified path to your modules' directory. You may also use the `modules_path` function to generate a fully qualified path to a given file relative to the modules' directory. + +This function works similarly to the existing `app_path` or `storage_path` helpers, allowing you to generate paths relative to the modules' directory effortlessly. + ## Comparison to `nwidart/laravel-modules` [Laravel Modules](https://nwidart.com/laravel-modules) is a great package that’s been diff --git a/composer.json b/composer.json index 0d1786d..1c68658 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,10 @@ "autoload": { "psr-4": { "InterNACHI\\Modular\\": "src/" - } + }, + "files": [ + "src/helpers.php" + ] }, "autoload-dev": { "psr-4": { diff --git a/src/helpers.php b/src/helpers.php new file mode 100644 index 0000000..7ab7b6e --- /dev/null +++ b/src/helpers.php @@ -0,0 +1,16 @@ +assertEquals($expected, modules_path()); + } + + public function testModulesPathWithArgument() + { + Config::set('app-modules.modules_directory', 'app-modules'); + + $expected = str_replace('\\', '/', base_path('app-modules/module/test.php')); + + $this->assertEquals($expected, modules_path('/module/test.php')); + } +} \ No newline at end of file