Coder Social home page Coder Social logo

nwidart / laravel-modules Goto Github PK

View Code? Open in Web Editor NEW
5.3K 153.0 939.0 1.81 MB

Module Management In Laravel

Home Page: https://docs.laravelmodules.com

License: MIT License

PHP 97.19% Blade 2.55% JavaScript 0.26%
laravel-modules laravel architecture php hacktoberfest

laravel-modules's Introduction

Laravel-Modules

Latest Version on Packagist Software License Scrutinizer Coverage Total Downloads

Laravel laravel-modules
5.4 ^1.0
5.5 ^2.0
5.6 ^3.0
5.7 ^4.0
5.8 ^5.0
6.0 ^6.0
7.0 ^7.0
8.0 ^8.0
9.0 ^9.0
10.0 ^10.0
11.0 ^11.0

nwidart/laravel-modules is a Laravel package created to manage your large Laravel app using modules. A Module is like a Laravel package, it has some views, controllers or models. This package is supported and tested in Laravel 11.

This package is a re-published, re-organised and maintained version of pingpong/modules, which isn't maintained anymore.

With one big bonus that the original package didn't have: tests.

upgrade

To upgrade to version V11 follow Upgrade Guide on official document.

Install

To install via Composer, run:

composer require nwidart/laravel-modules

The package will automatically register a service provider and alias.

Optionally, publish the package's configuration file by running:

php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"

Autoloading

By default, the module classes are not loaded automatically. You can autoload your modules by adding merge-plugin to the extra section:

"extra": {
    "laravel": {
        "dont-discover": []
    },
    "merge-plugin": {
        "include": [
            "Modules/*/composer.json"
        ]
    }
},

Tip: don't forget to run composer dump-autoload afterwards.

Documentation

You'll find installation instructions and full documentation on https://laravelmodules.com/.

Demo

You can see a demo using Laravel Breeze at https://github.com/laravel-modules-com/breeze-demo

This is a complete application using Auth, Base and Profile modules.

Community

We also have a Discord community. https://discord.gg/hkF7BRvRZK For quick help, ask questions in the appropriate channel.

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-modules's People

Contributors

4m1n0s avatar ahmedggalal avatar alissn avatar artemsky avatar arthvrian avatar aryala7 avatar balping avatar davidnadejdin avatar dcblogdev avatar debuqer avatar enterprime avatar fazers avatar jaberwiki avatar jnbn avatar kabbouchi avatar kyslik avatar lindo-llc avatar mikemand avatar nmfzone avatar nwidart avatar pickmanmurimi avatar rcbgalido avatar reinierh avatar rezrazi avatar rjvandoesburg avatar rspeekenbrink avatar schweppesale avatar solomon-ochepa avatar tentus avatar wikigods avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-modules's Issues

Policies/Exceptions within modules

Hi There,

Is is already possible, or do you have plans to allow for policies and exceptions to be within the modules created by laravel-modules?

For policies, it looks like it is possible with the registerPolicies function within the AuthServiceProvider. So would each module require an instance of the AuthServiceProvider to register their policies? Or would it be easier to register each module's policies within the global AuthServiceProvider?

I assume that exception classes will be auto loaded by default, so it is just a case of creating a folder within each module and place the exceptions in there?

Thanks in advance for any advice offered.

modules.used not found

Hello,

when I want to generate new middleware class in command,

show error :

[Illuminate\Contracts\Filesystem\FileNotFoundException]
File does not exist at path F:\xampp\htdocs\new\black\storage\app/modules/modules.used

how to fix that?

Thank you

Class not found

excuse me, I used your laravel-modules for laravel 5.3, but I 'm have difficulty,
I follow the steps install laravel-modules
when I type php artisan module:make Bulletin is ok
and then type php artisan module:list is not ok
because it show:
[Symfony\Component\Debug\Exception\FatalThrowableError] Class 'Modules\Bulletin\Providers\BulletinServiceProvider' not found

I checked the folder, this file exists.
Do I less steps !?
And other question can create route to Modules\Bulletin\route\api.php or web.php !?
And how do use restful api ?

thanks.

php artisan module:migrate-rollback, not working

Hi there, thank you for this package,

The problem is that when I execute

php artisan module:migrate-rollback

this error appear
[BadMethodCallException]
Method lists does not exist.

I search and found that laravel 5.3 replaced lists by pluck

Model names with upper cases

If you for example run this code: php artisan module:make NewModule. It generates all the files correctly except for the namespaces. It probably runs module name through an ucfirst() or something.

So after generating such module all three generated classes will be under namespace Modules\Newmodule. However, it should be under Modules\NewModule.

Support for Laravel LTS version (5.1)

I tried to integrate this package to a Laravel 5.1 project but get,
"ReflectionException in Container.php line 741: Class web does not exist" error when accessing module urls. more info: http://pastebin.com/baJgfzdt

Steps to reproduce

  • composer create-project laravel/laravel laravel_test_ii "5.1.*"
  • cd laravel_test_ii
  • composer require nwidart/laravel-modules
  • update config/app.php (provider & alias)
  • php artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"
  • update composer json ("Modules": "Modules/")
  • php artisan module:make Blog User Auth
  • composer dump-autoload
  • php artisan module:dump
  • php artisan module:list (enabled)
  • php artisan serve
  • http://localhost:8000/blog

Please support for LTS versions. And any idea how to solve this?

ServiceProvider Not Found

I'd like to say this is nice module.
It has an error that says afte creating Backend module.

Class 'CustomNameSpace\Backend\Providers\BackendServiceProvider' not found.

L v5.2.39

Module providers/alias dependency injection

I need to create a module for my project that uses multiple composer packages which I don't want to add to my master Laravel project. So I need to publish config files for each one of these composer packages in my module and not in my master project and I don't know what to do to achieve this by the information you have provided in your package information.

Here is a my module config file using "willvincent/feeds" package :

'name' => 'Rss',

'scan' => [
    'enabled' => true
],

'providers' => [
    willvincent\Feeds\FeedsServiceProvider::class,
],

'aliases' => [
    'Feeds'    => willvincent\Feeds\Facades\FeedsFacade::class,
],

and what I wanted to do is running this command : php artisan vendor:publish --provider="willvincent\Feeds\FeedsServiceProvider" but nothing happens. I think this is because of these two lines :

'providers' => [
    willvincent\Feeds\FeedsServiceProvider::class,
],

'aliases' => [
    'Feeds'    => willvincent\Feeds\Facades\FeedsFacade::class,
],

I will be glad if you help me fix this problem.

Best Regards

Cann't use Auth::guard inside middleware

Sorry for asking so many Question...

AdminMiddleware.php

Error:


ErrorException in Superadmin.php line 20:
Undefined variable: guard


namespace Modules\Superadmin\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;


 if (Auth::guard($guard)->guest()) {

L 5.3 problem..

Hello sir,

I need a help from you. I am about to start a project in office since today. I started in L5.3 and used your modules extenstion from GitHub. The problem is, after using modules plugin, no any class is being supported in my Controllers.

Eg: Input Class not found.

I used to do projects in L 5.1 where I used pingping-sky and everything was working well. When I compared those two modules created by pingpong in 5.1 and laravel-modules in 5.3, I found that

In modules created by ping ping : there is this line

use Pingpong\Modules\Routing\Controller;

set by default in Newly created module, which is not present in the module created by laravel/modules. Do you think this is the issue?

Hoping positive solution from you ! It would be an big help if you could take some of your time to reply this message.

Thanks !!

How to share a module to Github and Packagist

Hello, i have installed your package and organized laravel into modular structure.
I have created a module call User for example, how can i share to github ?
i want to know which folder of my module i need to GIT INIT?

can you show me some step?

thx
Create A Module.
Push the module to github.
Submit your module to the packagist website. Submit to packagist is very easy, just give your github repository, click submit and you done.

laravel collective dependency

I see in the main service provider the registerHtml method. Am I wrong or It's never used? Laravel Collective dependency is there for a legacy requirement?

No hint path defined for <Module> on view render

Hi, I have setup my base composer.json to have and created a module called "Auth":

"psr-4": { "App\\": "app/", "Modules\\": "Modules/" }

But when I try to render the view: "auth::login" it gives me the following error: "No hint path defined for [Auth]."

I understand that this is composer PSR-4 related error, however, I don't know how to fix it.

Do you have any ideas? I am running Laravel 5.3

Prioritizing routes

Is it any support for overriding default routes from the modules?

Say if I want to use subdomains instead of subfolder it would be easiest if subdomain.domain.com/something would override domain.com/something

At least kind of option to be set on the group / route to let it override the "default" routes

How to initialise my module middleware inside kernel.php file

Kernel file

 protected $routeMiddleware = [
 'superadmin' => \Modules\Superadmin\Middleware\Superadmin::class,
];

Module Route

Route::group(['middleware' => ['web', 'superadmin'], 'prefix' => 'superadmin', 'namespace' => 'Modules\Superadmin\Http\Controllers'], function()
{
    Route::get('/', 'SuperadminController@index');
});

Add command for generating job classes for module

Really like this package.
I would suggest you include commands for generating job classes within the module.

Such as
php artisan module:make-job SomeJob module

Also would love to have option for generating migrations for a model created.
For instance in L5 i could do
php artisan make:model TheModel -m
where the '-m' generates the migration for the model.
It would be nice to achieve that in the module

Thanks

serviceprovider not found on host

hi i have one module that is working fine on localhost which is windows, but my module got below error when i move it to linux hosting
FatalErrorException in Application.php line 598: Class 'Modules\SlideShow\Providers\SlideShowServiceProvider' not found

Bind main app event with module listener

Hey,

I've got event in my main application and handler/listener class in my new module - is there any way to bind those two classes in modules service provider? I tried adding

protected $listen = [ 'App\Events\MainAppEvent' => [ 'Modules\MyModule\Events\Handlers\EventHandler', ], ];

but it seems that it doesn't work :/

Schedule task per module

Hi!

First I'd like to thank you for your great job in maintaining this module :)

I have a question/problem - is it possible to declare schedule task in module? Is there any good practice for that or should I just check in my main applications app/Console/Kernel.php file that the module is present and declare task there?

Define Default Module

Hi,

I couldn't find a way to define default module to be loaded when entering my app.

In addition, is there any way to create hebrew routes for english-named modules?

How to use models from other Modules?

Say I have a User module.
And say I also have a Blog module.

The Blog module has a Post model/entity.

I want to use the User entity from the User module in a posts() relationship to the Post entity from the Blog module.

I.e. $user->posts()

In Ruby, this was possible by way of class_eval, which allows you to re-open an existing class and add methods to it. E.g., in this case we could've re-opened the User entity (which is from a different module) from within the Blog module and added a public function posts() method.

How can we do this in PHP and Laravel?

Cannot install on LV 5.1

Hi,

Can not install this package for LV v5.1 with this command:

omposer require nwidart/laravel-modules

Because composer.json file requires v5.2 for laravel.

Can you please modify it so it works with LV5.1 too as it is still widely used version.

Thanks

Laravel 5.3 routes update

Hello,
first of all I love laravel-modules and that you're taking care of this package. Would you consider the Laravel 5.3 support with the "routes" folder for all of the modules routes? The support for not adding unused folders by default would be really awesome as well.
Thanks

No way to publish seeders

It would be great if there was a command to publish database seeders. I sometimes use them within migrations as a means to initially populate a table, and would thus love to be able to publish them to the main database/seeds directory.

What is install module?

Install the specified module by given module name.

Module::install('nwidart/hello');

What it will do?

Module::install() not working

the Module::install() function not working,
but the command line php artisan module:install is working
how to fix this ?

Console Command

How to register them? I went through readme, but couldn't find an example of how to do it.

Loading order

Hi. Is there a way to load modules in a specific order?

How are modules loaded?

Hi,

I just migrate from ping-pon modules. Thanks for continue supporting this package!

I just noticed I don't need to add the module service provider to the application anymore. However I tried to deploy this but the application does not recognise de modules. I run php artisan module:list but there is no modules. I could add the service provider but I would like to know how it works in my local.

Thanks,

File does not exists modules.used

Hi,

I was trying to execute the following command

php artisan module:make-request LoginRequest

But, I got the following error.

File does not exist at path /laravel/storage/app/modules/modules.used

Laravel 5.3

Hi,

Any plans to support 5.3 since its released?

Problem 1
- Installation request for nwidart/laravel-modules ^0.10.0 -> satisfiable by nwidart/laravel-modules[0.10].
- Conclusion: remove laravel/framework v5.3.0

thanks

making a dynamic sidebar for modules

hi how can i make a dynamic sidebar for modules so it gets module names and routes then make anchor tags in sidebar dynamic?
any idea how to do this ?
i thin i shoud use config files for each modules and save my data, then retrive it? but how get all module's config data

Json module definition

Is there a specific reason for using json in module definition?

Why not plain php config files? Having to write service provider and alias in js is rather a pain...

[Module] Service provider not found on production server

I created Employee Module, but error message is appearing on production server like that

[Symfony\Component\Debug\Exception\FatalThrowableError]               
 Class 'Modules\Employee\Providers\EmployeeServiceProvider' not found

Development -> Mac
Production -> Ubuntu server 14.04, Nginx

I also run a composer dump-autoload and php artisan clear-compiled on production.

Application is running stable on development server.
I don't exactly know this error message. Please help me. Thanks

module:migrate-rollback doesnt take an --database option

hey there, thanks alot for this package it have been very useful to me ,i have been having a problem with trying to rollback a certain module in a certain database not the default one , it is working correctly with module:migrate by stating --database=connectionName

Service provider not found

I created Employee Module, but error message is still appearing like that

[Symfony\Component\Debug\Exception\FatalThrowableError]               
 Class 'Modules\Employee\Providers\EmployeeServiceProvider' not found

I don't exactly know this error message. Please help me. Thanks

RESTful controllers

From php artisan help module:make-controller:

Generate new restful controller for the specified module.

Correct me if I'm wrong, but should'nt it generate a controller with full stack of methods (index, create, store, show, edit, update, destroy), like default Laravel generator does and not just one index() method?

Ofcourse, if it would generate all those methods, then additional views are required or some message could be displayed that views are not present. Moreover, generated get() route should be changed to a resource().

Anyway, I think it should either generate all methods (with option to generate plain one), or generator description should be changed.

Don't boot or register not requested module

Since application is separated into modules, any http request should only access one module at a time.

Just imagine we have hundreds of modules, unrequested modules should not be booted or registered at all.

Should we provide a mechanism to archive this goal?

Controller class and file name missmatch

After running command like this: php artisan module:make-controller Users UserModule class named Users will be created, but file will be named UsersController.php. It should be consistent with appending Controller to either both or none.

Versionable modules

Hi,

In my system I've got products units table (part of Products module) where I keep pre-defined units: cm/mm/kg. Let's say I want to add extra unit to this table. My site is live (production) so I can't simply reinstall it to call a seeder once again with new values. I need to add new Seeder with just one line (new unit). It's not a cleanest way to do it. Is there any better way for that kind of actions?

Does it work for Laravel 5.2?

Hello @nWidart it is nice to hear that you are contributing to a modular approach. ๐Ÿ‘
I have a question that does this module works on Laravel 5.2 and will it be supporting the upcoming 5.3 version?
Thanks for the good work.

Why don't you use the package in AsgardCMS?

Hi Nicolas,
We use AsgardCMS as custom configured. Could we use this package instead of pingpong/module (which is not provided from you).

Do you plan to implement this package to AsgardCMS?

Thanks.

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.