module()Access the Module Registry or get configuration for a specific module.
Usage 1: Get Registry Instance
$registry = module();
// Returns \AlizHarb\Modular\ModuleRegistry
$config = module('Shop');
if ($config) {
echo $config['version']; // "1.0.0"
echo $config['namespace']; // "Modules\Shop\"
}
Modular FacadeAlternatively, you can use the facade for object-oriented access.
use AlizHarb\Modular\Facades\Modular;
// Get all modules
$modules = Modular::getModules();
// Check existence
if (Modular::moduleExists('Shop')) {
// ...
}
module_path()Get the absolute filesystem path to a module.
Usage 1: Module Root
$path = module_path('Shop');
// Result: "/var/www/modules/Shop"
Usage 2: Specific File
$path = module_path('Shop', 'resources/views/index.blade.php');
// Result: "/var/www/modules/Shop/resources/views/index.blade.php"
module_config_path()Shortcut to get the path of a config file inside a module.
$path = module_config_path('Shop', 'permissions.php');
// Result: "/var/www/modules/Shop/config/permissions.php"
module_asset()Generates a public URL for an asset. Use this when your asset has been published (via modular:link or Vite build).
Usage:
<img src="{{ module_asset('Shop', 'images/logo.png') }}" />
Result: http://your-app.test/modules/shop/images/logo.png
Note: The assumption is that assets are symlinked to public/modules/{module-lower}.
modular_vite()Renders the <script> and <link> tags for Vite HMR (Hot Module Replacement) or production builds.
Important: This implementation supports loading assets from any directory, not just the root resources/.
Usage in Blade:
<head>
<!--
Load the specific JS/CSS entry points for the Shop module.
This points to modules/Shop/resources/assets/...
-->
{{ modular_vite([
'resources/assets/css/app.css',
'resources/assets/js/app.js'
], 'modules/shop/build') }}
</head>
modules_path()(New in v1.1.5)
Get the absolute path to the root directory where all modules are stored (usually base_path('modules')), respecting the path configured in config/modular.php.
Usage:
$path = modules_path();
// Result: "/var/www/modules"
$nested = modules_path('Shop/module.json');
// Result: "/var/www/modules/Shop/module.json"
Laravel Modular provides expressive Blade directives to conditionally render UI components based on a module's activation status. This prevents tight coupling in your layout files.
[@moduleEnabled](https://github.com/moduleEnabled)Renders the enclosed HTML block only if the specified module exists and is enabled.
[@moduleEnabled](https://github.com/moduleEnabled)('Store')
<li class="nav-item">
<a href="{{ route('store.index') }}">Browse Store</a>
</li>
[@endmoduleEnabled](https://github.com/endmoduleEnabled)
[@moduleDisabled](https://github.com/moduleDisabled)Renders the enclosed HTML block if the specified module is disabled (or does not exist).
[@moduleDisabled](https://github.com/moduleDisabled)('Store')
<div class="alert alert-warning">
The Store module is currently undergoing maintenance.
</div>
[@endmoduleDisabled](https://github.com/endmoduleDisabled)
How can I help you explore Laravel packages today?