Git Product home page Git Product logo

l5modular's Introduction

L5Modular logo

L5Modular

Keep Your Laravel App Organized


latest release build maintainability code coverage downloads All Contributors license


This package allows you to organize your Laravel project in a modular manner.
You can simply drop or generate modules with their own controllers, models, views, routes, etc. into the app/Modules folder and go on working with them.


Documentation

Check out the full documentation at l5modular.github.io


Installation

The easiest way to install this package is through your terminal via Composer.
Run the following command in a bash prompt from your projects root

composer require artem-schander/l5-modular

Requirements

L5Modular v2 requires at least PHP 7.2 and Laravel 5.7
Older PHP / Laravel versions are supported by L5Modular v1.




Contributors

Thanks goes to these wonderful people:


Julio Motol

πŸ’» ⚠️ πŸ”§

Hussein Feras

πŸ’» ⚠️ πŸ”§

Farhan Wazir

πŸ’»

David HΓΆck

πŸ’»

Kis Viktor

πŸ’»

Akram Berkawy

πŸ’»

Thomas Eriksson

πŸ›

Also thanks to zyhn for the "Modular Structure in Laravel 5" tutorial. Well explained and helped a lot.




Contact

Feel free to join the Slack chat.




License

L5Modular is licensed under the terms of the MIT License (See LICENSE file for details).

l5modular's People

Contributors

allcontributors[bot] avatar artem-schander avatar farhanwazir avatar tombombadilll 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

l5modular's Issues

Multiple include during testing

PHP Fatal error: Cannot redeclare is_active_menu() (previously declared in /xxx/app/Modules/Admin/helper.php:29) in /xxx/app/Modules/Admin/helper.php on line 29

include_once could solve the issue. Why do you use include here?

Class L5Modular not found

Describe the bug
Installed this package on clean laravel 8.12 and jsut make a new module call Faq.

After this I just go to https://l5modular.com/usage/#facade

and using first one

L5Modular::exists('HelloWorld');

and it give me following error

Error
Class 'L5Modular' not found
http://localhost:8000/test/

To Reproduce
Steps to reproduce the behavior:

  1. Install new laravel and this package.
  2. Make any module after setup the package.
  3. Make a test route and use any facade from docs or the exists() one.
  4. You will get class not found error.

Expected behavior
It should return true or false as per docs.

Screenshots

image

Environment (please complete the following information):

  • OS & version: Windows 10 Build 19042
  • Laravel version: 8.12
  • L5Modular version: 2.1

Auth redirect

Sadly this does not work so well when you try to use Auth.

For example if you put
public function __construct() { $this->middleware('auth'); }

inside a controller the login will always push you to /home

if you add ->middleware('auth'); at the end of a route it does not work.

Also if you add auth to the middle ware group it also does not work.


<?php

Route::group(["module" => "Admin", "middleware" => ["web","auth"], "namespace" => "App\Modules\Admin\Controllers"], function() {

    Route::resource("admin", "AdminController");

});

How to create each config file ?

If each module developed by different person or team, and each module have config file (config.php), how to do that ? I can't use if I put config.php in root of module.

Livewire support

Hello, guys.

It would be great if we could have Livewire support in this package, so we could create Livewire components and views inside each module.

Is it possible?

Thank you.

Translation file wrongly generated

When creating a new module, the translation file appears in Foo/resources/lang
this is would never work please change it to:
for example:

  • resource/lang/en/en.php

Migration Split

Thank you for making this, it works perfectly.

Is there a way to make the migration in the module folder. This way we could run the migration from the module itself.
Now I have to run a migration every time I make a change resting my entire environment. I feel if that would be the case I could only run migration on that one module and not on all the others.

Use global routes.php together with modules route.php

Hello there,

I am currently looking for a hint how to use the global routes.php in Http\ since I have some code that has to be globally available, e.g. the main system. I would like to extend this main system with modules and thus use the routes.php file inside the modules folder but if there is any content in my routes.php, the ones in the module folders are ignored.

Any Idea how to "fix" that?

Nested Modules

Is your feature request related to a problem? Please describe.
when you building a module structure project or HMVC (Hierarchical model–view–controller)
sometimes you need to use nested modules (module inside the module)

Describe the solution you'd like
add an artisan command to create a submodule (php artisan module:make:module Bar --module=Foo)
or (php artisan make:module:submodule Bar --module=Foo)

Additional context
great job guys, I wish you consider these feature in the next updates

Translation

How can i access translation at Module controller by using trans() method ?

Routes not detecting when vhost

Routes not found when vhost is setup, but in running artisan serve it can get the routes. I'm using laravel 5.3. Any idea?

Not working with Laravel < v5.1.1

I have been using this package for about an year now and am very pleased with how easily it manages modules in a project.

But, I am still using my project with Laravel 5.1.1 and recently noticed (when doing some composer updates) that it was throwing the following error. http://imgur.com/iAUlGSC

So, is there anyway I can get over this issue or it no longer supports Laravel less than v5.1.1?

Any help is much appreciated.

Thanks in advance.

Route problem

Hi there,

Could you please help me out with a problem with this package. Actually the problem is that when I try to protect my routes with auth middleware in the web.php file, then the auth middleware doesn't work, but however if I use the middleware in the api.php file then the routes in the web.php is also protected.

It seems that the package is prioritizing api.php file before web.php file. I hope I have made the situation clear.

Thanks

model not working

I write on model and contlloer it is now wokring

        $filght = Blogs::all();
    print_r($filght);

"Model"

Add functional arrilot/laravel-widgets

I liked the arrilot/laravel-widgets functionality.
Roughly add widgets through the module:

class ModuleServiceProvider

use Illuminate\Support\Facades\View;

function boot()

$widgets  = app_path().'/Modules/'.$module.'/Widgets';

if ($this->files->isDirectory($widgets)){
	$directories = $this->files->directories($widgets);
	foreach($directories as $Widjet){ 
		$WidjetViews = $Widjet."/Views";
		if ($this->files->isDirectory($WidjetViews)) {
			View::addNamespace('Module.'.$module.'.Widget', $WidjetViews);
		}
		$controllerList = $this->files->files($Widjet);
		foreach($controllerList as $controller){
			include_once($controller->getPathname());
		}
	}
} 

laravel-project/
    app/
    └── Modules/
        └── FooBar/
            └── Widgets/
                └── Widget/
                     └── Views/
                          └── bar.blade.php
                     Bar.php

view('Module.FooBar.Widget::bar')

Route cache not working

When using this module I noticed that route caching don't work on the routes.php files in the different modules.

I would suggest this solution in the ModuelServiceProvider file:

// Allow routes to be cached
if(is_dir(app_path().'/Modules/')) {
$modules = config("modules.enable") ?: array_map('class_basename', $this->files->directories(app_path().'/Modules/'));
foreach($modules as $module)  {
// Allow routes to be cached
if (!$this->app->routesAreCached()) {
    $routes = app_path() . '/Modules/' . $module . '/routes.php';
    if($this->files->exists($routes)) include $routes;
}
$helper = app_path().'/Modules/'.$module.'/helper.php';
$views  = app_path().'/Modules/'.$module.'/Views';
$trans  = app_path().'/Modules/'.$module.'/Translations';

if($this->files->exists($helper)) include $helper;
if($this->files->isDirectory($views)) $this->loadViewsFrom($views, $module);
if($this->files->isDirectory($trans)) $this->loadTranslationsFrom($trans, $module);
}
}

routes not working

I used zyhn tutorial, it was working fine but in your package same code, my module routes.php is included but Route::get not working.. any hint?

Error when using action()

Hello.

I've updated L5 Modular in my project from V1 to V2.

I've set the config file to load the V1 modules, but now I'm getting this message:

Target class [App\Modules\MyModule\Controllers\App\Modules\MyModule\Controllers\MyController] does not exist.

I think that this is happening because some of the project developers have used the action function with the full path to the controller method [Ex: action('\App\Modules\MyModule\Controllers\MyController@index');] and L5 Modular makes the concatenation beetween the module path and with the action parameter.

Can someone help me with this?

Thank's!

include auto discovery

include auto discovery ServiceProvider in your composer.json

"extra": { "laravel": { "providers": [ "ArtemSchander\\L5Modular\\src\\ModuleServiceProvider" ] }

config files for a specific module

Is your feature request related to a problem? Please describe.
many of the time a module need a configuration that can be published to the main project
this feature in so important to the modules structures and make it easy to reuse the module in other projects with different configurations

Describe the solution you'd like
It would be awesome if I can add a config file for my module for example:
app/Modules/FooBar/config/config.php

Describe alternatives you've considered
and if you add an artisan command like (php artisan make:module:config) that would be awesome too

Additional context

Extend Laravel's scaffolding commands to generate in a certain module

Hi, thank you for providing this awesome package. Our team have been using this for years now. As good as it is, it can be troublesome to generate controllers,models, etc. using Laravel's scaffolding commands. It would be nice if we could just run php artisan make:controller SomeController --module=SomeModule and the generated controller will be inside the assigned module.

I have forked this repo and tried implementing this, you can see the branch here. I've only applied what I think is sensible to be placed in their respective module (e,g, events, jobs, listeners, etc.). I can exclude or include others if you so desire, just let me know.

I've done some light testing on it but I'd like to know how you properly test this so I could too before I make a PR for this.

How reference views path?

Hi.

How reference views path in route?

If my view is named "bar" and is in Modules/Foo/Views, the code doesn't works

Route::get('example', function () {
return view('foo.bar');
});

Modules namespaces and routes

How to use namespace Admin/Module_name and User/Module_name ?

folder routes not auto use ... :-(

image

Admin/routes/web.php Work (Module auto use only this path)

Admin/Test/routes/web.php Not Work

How to create ConsoleCommand?

All work just fine, I can generate a module with Controller, Model and etc, but now I need to create a console command in my module. How can I do it?

Help setting up L5Modular V2 to work with existing V1 Modules

Hello, guys.

I've updated the L5Modular of my project to version 2 and I'm trying to make the V1 Modules to work, but without success.

I follow the documentation, and added my existing modules to the config file like this:

'specific' => [ 'MyModule' => [ 'enabled' => true, 'routing' => [ 'simple' ], 'structure' => [ 'controllers' => 'Controllers', 'models' => 'Models', 'requests' => 'Requests', 'translations' => 'Translations', 'views' => 'Views', 'migrations' => '', ], ]

What am I doing wrong?

Mongo db Auth error

Check my question here http://stackoverflow.com/questions/32155875/laravel-5-1-modular-structure-create-two-type-of-login

Also getting error with Simple Auth
Argument 2 passed to Illuminate\Database\Query\Builder::__construct() must be an instance of Illuminate\Database\Query\Grammars\Grammar, null given, called in /var/www/newlara/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php on line 1899 and defined

Code here https://www.dropbox.com/sh/tbj83gvxblctkvi/AADQjF_X2DaJ5FpRZWVD-mdia?dl=0
I am using mongo db

unable to check route:list after moving controller to folder

ss33
ss3434

"AppointmentController" has been created with the Module. I can't check route:list if I move/delete the Controller that created with the module. I tried creating a new controller inside the folder with same name and delete the old one which was created when I made the module but It doesn't work. I can't find any solution . Please tell me if there is any way to solve this.

What I want to do is to move the controller into "backend or frontend" folder to separate it and also check route:list without any issue. I got no issue other than that It works fine It's just I can't check route:list If I move the controller (which was created with module) to any folder.

Routes not working on server

I'm having issue when uploading the application to my server, but on my local it working fine
Error message are:

in RouteCollection.php line 143
at RouteCollection->match(object(Request)) in Router.php line 746
at Router->findRoute(object(Request)) in Router.php line 655
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 54
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 53

artisan route:cache fails

artisan route:cache command fails due to more than one inclusion of the helper.php files.

I have fixed the issue with updating "include $helper;" to "include_once $helper;" in boot() method of ModuleServiceProvider class.

How to use vue single file component?

I am building a large system with vue and vuex. This module system doesn't have "assets" or any directory where I can put my front-end logics in here.

How can I implements this feature?

Thanks

Migrations in the old way

Hey guys

How can I generate migrations in the standard way like in the previous versions ?
I've played around with config files but no way

UPDATE :

I had to edit this method here in MigrateMakeCommand Class

 protected function getMigrationPath()
    {
       
        $migrationPath = $this->laravel['path'] .'/' . $this->getConfiguredFolder('migrations');
   
        if (! is_null($targetPath = $this->input->getOption('path'))) {
            return $migrationPath . '/' . $targetPath;
        }

        return $migrationPath;
    }

is there a cleaner way to make this change ?

Module Route with middleware auth not works

Hello, first of all thank you for your works!

I'm using your module, but i think to have find a problem. Default routes of module (web.php) is:

Route::group(array('module' => 'Test', 'middleware' => ['web'], 'namespace' => 'App\Modules\Test\Controllers'), function() {
 //list of my routes, for example 
 Route::get('/test', 'TestController@testIndex');
});

If i would like to protect my routes by middleware, i should change Route::group like that:

Route::group(array('module' => 'Test', 'middleware' => ['**auth**'], 'namespace' => 'App\Modules\Test\Controllers'), function() {
 //list of my routes, for example
 Route::get('/test', 'TestController@testIndex');
});

If i change Route::group like example above when i try to go to "/test", i will be redirect to "/". My suspicion is that auth middleware are not loaded in right way inside module, maybe for different namespace?

The only way i finded to workaround, is to edit routes.php of project (not of module!) adding inside Route::group(['middleware' => ['auth']], function() {
[...]
Route::get('/test', '\App\Modules\Test\Controllers\TestController@testIndex'); [...]

This is no a really useful way to solve the problem. What i can do to solve that problem in web.php of module, istead of edit main Route file?

Best Regards,
Simone

laravel 5.1 not supported

How to use the cool generator on laravel 5.1.x
If I use 5.3.x no commands are available on artisan console.

Please help me fixing that

Kind regards

Peter

Case-sensitive module naming issue

Hi sir,
I have create a modul name "Product" and run perfectly when i opening test.dev/Product in my browser. But return error "NotFoundHttpException in RouteCollection.php line 179:" when i open test.dev/product (in lowercase). There anyway to ignored this case-sensitive? Thank you

studly_case() undefined

Call to undefined function ArtemSchander\L5Modular\Console\studly_case()

hi, I always get this error when making a module, I tried to remove the studly_case and other function indicated on the error, and it works, I hope you'll fix this for laravel 6.*

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.