Giter Club home page Giter Club logo

laravel-modules-livewire's Introduction

Laravel Modules With Livewire

Using Laravel Livewire in Laravel Modules package with automatically registered livewire components for every modules.

Installation:

Install through composer:

composer require codions/laravel-modules-livewire

Publish the package's configuration file:

php artisan vendor:publish --tag=modules-livewire-config

Making Components:

Command Signature:

php artisan module:make-livewire <Component> <Module> --view= --force --inline --stub= --custom

Example:

php artisan module:make-livewire Pages/AboutPage Core
php artisan module:make-livewire Pages\\AboutPage Core
php artisan module:make-livewire pages.about-page Core

Force create component if the class already exists:

php artisan module:make-livewire Pages/AboutPage Core --force

Output:

COMPONENT CREATED

CLASS: Modules/Core/Http/Livewire/Pages/AboutPage.php
VIEW:  Modules/Core/Resources/views/livewire/pages/about-page.blade.php
TAG: <livewire:core::pages.about-page />

Inline Component:

php artisan module:make-livewire Core Pages/AboutPage --inline

Output:

COMPONENT CREATED

CLASS: Modules/Core/Http/Livewire/Pages/AboutPage.php
TAG: <livewire:core::pages.about-page />

Modifying Stubs:

Publish the package's stubs:

php artisan vendor:publish --tag=modules-livewire-stub

After publishing the stubs, will create these files. And when running the make command, will use these stub files by default.

stubs/modules-livewire/livewire.inline.stub
stubs/modules-livewire/livewire.stub
stubs/modules-livewire/livewire.view.stub

You're able to set a custom stub directory for component with (--stub) option.

php artisan module:make-livewire Core Pages/AboutPage --stub=about
php artisan module:make-livewire Core Pages/AboutPage --stub=modules-livewire/core
php artisan module:make-livewire Core Pages/AboutPage --stub=./

Extra Option (--view):

You're able to set a custom view path for component with (--view) option.

Example:

php artisan module:make-livewire Pages/AboutPage Core --view=pages/about
php artisan module:make-livewire Pages/AboutPage Core --view=pages.about

Output:

COMPONENT CREATED

CLASS: Modules/Core/Http/Livewire/Pages/AboutPage.php
VIEW:  Modules/Core/Resources/views/livewire/pages/about.blade.php
TAG: <livewire:core::pages.about-page />

Rendering Components:

<livewire:{module-lower-name}::component-class-kebab-case />

Example:

<livewire:core::pages.about-page />

Custom Module:

To create components for the custom module, should be add custom modules in the config file.

The config file is located at config/modules-livewire.php after publishing the config file.

Remove comment for these lines & add your custom modules.

    /*
    |--------------------------------------------------------------------------
    | Custom modules setup
    |--------------------------------------------------------------------------
    |
    */

    // 'custom_modules' => [
    //     'Chat' => [
    //         'path' => base_path('libraries/Chat'),
    //         'module_namespace' => 'Libraries\\Chat',
    //         // 'namespace' => 'Http\\Livewire',
    //         // 'view' => 'Resources/views/livewire',
    //         // 'name_lower' => 'chat',
    //     ],
    // ],

Custom module config details

path: Add module full path (required).

module_namespace: Add module namespace (required).

namespace: By default using config('modules-livewire.namespace') value. You can set a different value for the specific module.

view: By default using config('modules-livewire.view') value. You can set a different value for the specific module.

name_lower: By default using module name to lowercase. If you set a custom name, module components will be register by custom name.

Credits

License

Laravel Themes Manager is open-sourced software licensed under the MIT license.

laravel-modules-livewire's People

Contributors

fabioassuncao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.