Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

maxccarvalho's avatar

Laravel 5 multi-app or modular applications

Do you think that laravel 5 wiil support multiple applications? Like modular applications?

I'm working on a project that will handle multiple modules that will be managed by the Core Module. The core module will be responsible for users, groups, permissions and even packages (modules) management.

So, imagine that the Core application have the users, and the users can need access to a Ticket Support tool. This tool can be build and pulled into the Main application, to be linked to the Core, using Core resources. And like that so many other applications can be pulled in, and this applications can share resources.

Many thanks for any opinion!

0 likes
26 replies
thepsion5's avatar

What do you mean by support? I could see how this would be fairly easy to do using packages and service providers. You could probably have your core service provider determine which modules should be enabled from a config file and then create and register/boot the required module service providers on its own.

3 likes
maxccarvalho's avatar

This is a good approach but, I'm thinking the way that the applications, or modules, will be dependent on the Core application so, do you think that the packages is a good solution?

Other issues: - what about routes? Any module can have its own routes. - The Core module should have the power to grant access to the other modules, so, I need to list the modules, thinking this way, the packages approach, in your opinion, is still a good solution?

In a nutshell, the MAIN module needs to "hold" the other modules. This application will have a installer to, like a Google Apps installer. This application will be available on the cloud, so clients will can create accounts, add premium features and etc.

Sorry about making this large text but, I'm just trying to explain myself, maybe I'm not so good with that.

maxccarvalho's avatar

So many thanks to @thepsion5 for opening my mind. I did a quick research about packages and workbench in Laravel world and my question is answered!!!!

1 like
maxccarvalho's avatar
maxccarvalho
OP
Best Answer
Level 6

@shuogawa I'm now using the composer packages approach. I have my main application that lies on the normal Laravel structure. This application holds users, and groups, and packages register, and general permissions to this packages.

Every package (module) is a composer package, that way any developer can contribute and build your own package, submit to approval and later this package can be available to install.

jacobson's avatar

I've read about laravel packages because I had the same problem with my application. I need to create app with 4 different modules with some common classes like authentication. But still I cant really imagine my Admin module to be created as a package. It would consist of "many" controllers with kinda wide functionality. I want to create this app in "laravel way". I'd appreciate any suggestions. Is my way of thinking ok ? Should I create a package for each "module" or this should more look like HMVC architecture using for example Pingpong modules ?

Best regards

maxccarvalho's avatar

@jacobson I decided to use composer packages because with that approach any developer can contribute to the main application, using PHP and composer.

jacobson's avatar

Well u're right but in my case I just want to create my own multi module project not necessary available for other developers ;)

1 like
maxccarvalho's avatar

Well, I believe that you can use some module package but, keep in mind that the framework is always receiving upgrades so, the module packages must follow the changes.

shuogawa's avatar

@nWidart @maxccarvalho
sorry late reply. I dont want to create multi app by composer,package, or module approach. Because I dont want separate repository of apps.

In laravel5, we might be able to control multi apps by AppServiceProvider. I will continue to think about how to make multi apps in laravel5.

Thank you.

keevitaja's avatar

@shuogawa what is a multi app? Most apps have multiple tasks and have more than one functionality. If you wanna break your code into pieces then you have 2 options. First would be to create a folder structure where each "module" has it's own folder and namespace or you could use composer packages.

If i had to do this, i would probably go with composer packages as it would be easier to update single package that way. And in laravel there is no big difference if you write your code in packages or not. Most other frameworks differ in that department.

nWidart's avatar

@shuogawa That's not a problem. Look at my platform package, it has the main modules for a functioning admin panel, in one repository. The modules are subtrees.

shuogawa's avatar

@nWidart thank you very much, but sorry.I do not want use git sub-tree.

@keevitaja I think multi app is not muti tenant app. it has at least two domain like www.example.com and manage.example.com. Separated resources are public, routes, controllers, storage/framework, and views. Shared resources are models, storage/app, and config.

There is one document https://medium.com/laravel-4/laravel-4-multisites-26cdc75e4810.

But I do not want shared public and routes.

I have to reset my head.Thanks.

webreinvent's avatar

Hello Guys,

Is there a way to restructure laravel 5 like following:

lv5
   app
     Commands
     Console
     ...
   bootstrap
   config
   storage
   vendor

Modules
  ModuleOne
     database
        migrations
        seeds
     Http
        Controllers
        routes.php
     models
     resources
       assets
       lang
       views


  ModuleTwo
     database
        migrations
        seeds
     Http
        Controllers
        routes.php
     models
     resources
       assets
       lang
       views

Let me know what you think about this approach. Main idea about this approach is to separate each modules independent of each other.

1 like
jagltoro's avatar

The main idea is not to use 3rd party code. Laravel should provide the flexibility to do it by itself

I understand the idea of webreinvent. And its make laravel more like Symfony is..

shuogawa's avatar

I`m back!

With Laravel5.1

Directory structure is

app/
    Http
    Controllers
        Admin
            IndexController.php
        Www
            IndexController.php
    routes.php
public_admin
    index.php
public_www
    index.php

routes.php is

Route::pattern('wwwHost', '(www\.example\.com)');
Route::group(['domain' => '{wwwHost}'], function (){
    \Route::get('', 'Www\IndexController@index');
});

Route::pattern('adminHost', '(admin\.example\.com)');
Route::group(['domain' => '{adminHost}'], function (){
    \Route::get('', 'Admin\IndexController@index');
});

This works well.

shuogawa's avatar

@MartinCarvalho

I set different document roots for both domains. Document roots are separated.

app/
    Http
    Controllers
        Admin
            IndexController.php
        Www
            IndexController.php
    routes.php
public_admin  <- document root for admin.example.com
    index.php
public_www <- document root for www.example.com
    index.php

Please tell me about your problem more!

shuogawa's avatar

Hi. @punchi

Do you inserted those directories in providers and/or composer.json too?? 

No. You can store models to your favorite directory. And if you want support multi auth, you can use Laravel5.2 Multi-Auth feature.

My project structure is below.

app/
    Http
        Controllers
            Admin
            AuthController.php
                    IndexController.php
            Www
             AuthController.php
                    IndexController.php
            routes.php #I am using route-group-sub-domain-routing
  User.php
  AdminUser.php 
public_admin  <- document root for admin.example.com(With Nginx or Apache config file)
    index.php
public_www <- document root for www.example.com(With Nginx or Apache config file)
    index.php
composer.json
IeD3vil's avatar

I have a working model of my vision on this... but for something different... say i have a CMS and i want to install it for 3 clients... i get 3 source codes that i have to maintain... and that's a pain in the ass. I set up a provider that takes a config for each of the 3 clients and boots up selecting the right database, setting up the template folder for the frontend (backend is the same), etc. I also have artisan commands that run migrations / etc for every instance... selecting the right "client" app is done on domain matching for now. I just point my domains to the same vhost and it works

Please or to participate in this conversation.