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.
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!
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.
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!!!!
Could you show me your multi-app directory structure?
I sent alike question at
http://laravel.io/forum/10-05-2014-how-to-create-multiple-applications
https://github.com/laravel/framework/issues/5914.
But now I am wondering.
Thank you.
I'm using the Pingpoong/Modules package to handle my modules, still in active development, but works very well. :)
@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.
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
@jacobson I decided to use composer packages because with that approach any developer can contribute to the main application, using PHP and composer.
Well u're right but in my case I just want to create my own multi module project not necessary available for other developers ;)
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.
@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.
@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.
@maxcarvalho Just for curiosity: Your modules will define permissions? How will you manage them? Thanks!
@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.
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.
Use this package http://sky.pingpong-labs.com/docs/2.0/modules
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..
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.
Hey @shuogawa , I´ve been trying to do something like this but found some problems when using multiple Public folders.. (https://laracasts.com/discuss/channels/laravel/multisite-cms-one-backend-same-server-folders-assets-general-structure-concerns).
I wanted to have specific files for each app. How did you set specifc public folders for each view?
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!
Hi @shuogawa ! Do you inserted those directories in providers and/or composer.json too?? I need to share some models, use "Auth::loginUsingId();" BUT i need different authentications
@MartinCarvalho did you resolve the problem?
The closer solution to you is this one http://ziyahanalbeniz.blogspot.com.tr/2015/03/modular-structure-in-laravel-5.html have your tried it? thanks!
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
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
@webreinvent, You may do so by mrabbani/laravel-module-manager package.
I use that structure for my current project inspired by django framework. The main reason is so I can easily install my apps to another project if needed. Check it here https://github.com/viender/viender
Please or to participate in this conversation.