Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Modular Laravel Package

alizharb/laravel-modular

View on GitHub
Deep Wiki
Context7

Helper Functions

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 Facade

Alternatively, 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"

Blade Directives

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)
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony