I'm working on a platform which runs multiple Laravel applications that interact via a single database.
Each Laravel instance is responsable for it's own logic, i.e:
Admin module (own subdomain)
User module (own subdomain)
Homepage module (own domain)
Saas-ish module (different domains)
Now the problem im facing with routing is the following:
I want to be able to create/generate URL's for the other modules in my platform and for each of the domains inside the Saas-ish module
Things i've thought about
Option 1
Make routes a shared folder/file (via git submodules or a package) and generate the route file based on the Saas domains and subdomains with the domain group option (and cache it). While this is a viable option, I'd prefer not to load a massive file with all the routes, when all I need is 1 or 2 per request.
Option 2
All routes in the DB. Make a RouteGenerator which will handle this for me. However I'm thorn in this option, because I think it the domains in the Saas module, (which are basicaly entities in my DB) and the other module's subdomains (which arn't entities in my database) are too different. So this may not be the best option.
One of these might be the solution for my problem, and i'm just not seeing it, OR it's something completely else.
Please share your insight...
No. Just no.
Here is your option: Merge.
This is more or less not optional. You never run the same framework multiple times for different parts of an app. It's a waste of space and awful to maintain.
You MUST merge your application into one.
Related
When should we use multi-module structure (instead simple structure) in php Phalcon?
I have found some multi-module skeleton, such as:
https://github.com/ovr/phalcon-module-skeleton,
https://github.com/phalcon/mvc/tree/master/multiple.
But I don't know should i use this multi-module structure in a project instead use multi projects.
Something i can think about it is: more complex configuration, complex folder structure, my web url be longer (/[module]/[controller]/[action]) and , importantly, performance will be low (for more loading things than).
However, I think that there are something interesting with it (so many ITer had used it). Is there Someone can give me advantages, disadvantages and criterias for selection.
P/s: the same problem with Zend2 Module!
If you are building a single purpose application as an API that does not use Views, you should rather use single module structure. If it will be a realy simple API of for example storing/logging, micro app will do aswell.
Multi module application structure is useful if you are willing to build more complex solutions. For example an public application with public content, but with admin panel. This one would be handy to write in multi-module to separate administrative controllers/views from those public ones.
My habit is to use multi-module structure, because mostly I have to build applications that are CRM's with their API and an public accessible content part (eg. docs). For such purpose it's just handy to create such modules as:
frontend - for controllers accessible by everyone
backend - for controllers accessible after authentication and authorisation like administrative things
API - for API purposes ;)
common - a part I rather am willing not to implement, but in one project I'm forced to put here some abstract controllers that will be extended in other modules.
This way you can keep separate services configuration for each module, what saves you from cutting off things that you are using at purpose of module A, but not on module B. Like authentication part - important for backend, but useless for frontend part. Or Database configuration - slaves for frontend, master for backend, etc. So this may be also a performance-wise solution for big projects.
Update
Sometimes "multi-project" is an option including "multi-module" project ;) It strongly depends on what you are trying to achieve. Eg. if you take API apart, it may be easier to scale it over multiple instances, but at first it costs you an efford to configure separate project.
If system is supposed to be single-server instance or every istance should be absolutely independed on other instances, single multi-module project will be enough - lets say a standar CMS, blog platform, even simple browser game or homepage of mobile app including API for it. But if you are building a whole universum of apps like an internal API to privide content, CRM to manage it and a couple of web pages to serve it, keeping these as separate projects will be easier to manage later.
Well for example I in my application im splitting every functionnality - for example i have model Link - it's splitted to seperate module to have nice application structure where each funtionality is seperated module. It's like less classes to load in loader. Beacause you only need models and routes from each module to load for whole app, and you load other things like librarys/controllers/helpers/services in module.
What is the best way to create a single page module for Yii2?
For example using Ember, I will have index.html and assets folder to publish.
I see two ways, one would be to just put the application under web accessible folder, it will work fine.
But what if i want to check access to the application using existing RBAC?
Another way would be to create a module and in default controller have something like
return $this->renderFile('#path/to/index.html');
And load all assets with Asset Bundle.
The problem with this approach is that i will not know the folder where assets will be loaded (it can be solved with afterCopy callback or something, but all this doesn't look nice at all).
Please advise.
Certainly it is a personal choice technique, since control RBAC is manageable level action and does not pose any problem. Once the controller is easy applicarre your organization's access control using a suitable configuration of the Access Control filter.
Alternatively, the fact of creating a module appropriately for these purposes makes it all the better organized and, precisely, modular, beyond the greater complexity in the creation of the various parts in play (module, asset, cofig / main.php) yii2 handles very well and automatically the assets and necessariio not know a priori in the name of the folder where I finish the specific assets (Yii2 find what they need).
However if this is not a 'module' with reusable application characteristics I would opt for the first solution
This is the situation i am currently having issues with:
I have 1 webserver, this webserver must run 2 different websites, those websites are all written in symfony2 and share the same Bundle that i wrote.
Currently this bundle is placed in the src/ folder and loaded in the AppKernel.
Right now i am using the apps approach where i have 2 seperate app folders created in 1 folder called apps ( http://jolicode.com/blog/multiple-applications-with-symfony2 )
However right now my situation changed, i have this 1 webserver with 2 different websites but i also have a second webserver which must also be able to have multiple apps.
Both servers should not share the same configuration files which is having me a lot of difficulties with deploying.
I also want to prevent that i have to deploy unused bundles to a server.
I hope i explained everything as clear as possible, it is not easy to make a description.
As I read, the app folder contains all config or not files related to the app ( doctrine, Kernel, cache, logs, etc). Routing, Services or other files related to how works an specific bundle should be within that bundle in my opinion.
I think there is not a standard or good way to do this because symfony right know has the workflow one app - one project. Any structure which separates bundle config and app con
fig is valid if don't mix both kinds
I've done a lot of research and before I get into this new project I wan to ask you for opinon of arhitecture I should take.
I am creating an application that is build with multiple modules that are not connected and I want to sperate them as modules. They will be developed separately. Now I want to find a best way to create this in ZF. First idea was to just change path to zf library to external resource and put every project seperate but then session and variables that needs to be common are seprate wich isnt good. What I want is single authentication point (like sign-in on google) and then have this modules (like gmail, calendar, google search etc.).
Next idea is to build subdomains and based on them do some routing: api.example.com -> api module, account.example.com -> another module etc. I found this here: Zend Framework 2 Routing subdomains to module or here Adding sub domain based routes in Zend framework .If this is the right way wich is better?
Another idea is to switch settings in bootstrap. So if request comes from api subdomain set APLICATION_PATH to api/ else to something else. But I dont think I could use same session then.
Third is to create rest auth service and then use the second way to achive this.
Any suggestions or ideas how could I achive this?
Sei ying there is no special move that is best, it all depends, any
move could be best, its up to you when the times right, to move
correctly, accurately and with great speed...
To sum it up: you have to choose which methods are best for your use case.
Developing separate Modules doesn't mean they won't share the same session once put into one application. There are already dozen of Authentication Modules out there that are able to connect to authenticate against google, too.
If you develop said modules: "Login", "Calendar", "Gmail" and then you put them all into your "MySuperApplication"-Application, then those will share the same browser-session. You'd however make sure that each of those has the proper interfaces to talk to each other.
It's really difficult to answer your question as it appears that you do not really understand the basics of how ZF2 works, therefore my only suggestion can be to start developing and come up with real questions ;)
I'm developing a component which has the below structure. This system is developed under Multi-Tenant concept.
www.a.com, www.b.com, www.c.com are web sites which are in different domains but they run the same system. Each website have their own template and web pages in their local database. That's doable.
The system which is ran on these three sites are independent from the mentioned above(templates etc). www.a.com, www.b.com, www.c.com have a one large database where all the system data is maintained. Since the system is developed according to MVC what I want to do is have a single model(multiple models) where all the logic is contained. So if I make a single change in the model it affects the 3 sites.
According to my research, model should be maintained in the cloud. How can I implement such a requirement with MVC(Given I'm using Joomla as my CMS, MySQL as DBs) ? How can I have a single model for all the 3 sites ?
You can put more than one domain on the very same joomla installation without any changes, just add a plugin that's called virtualdomains which will allow you (for free) to choose template and - thus - menus, extensions and available pages for each domain;
Maintenance-wise this will be easy since all is in one box; but the users will see three sites with different content, layout and urls.
Just a couple of warnings:
1) make sure no scripts or css or other local resources are invoked with the url (http://www.a.com/template/xxx/js/jquery.autocomplete.js) vs /template/xxx/js/jquery.autocomplete.js, the first will work badly with cache.
2) handle any intricacies such as same-url on different domains with .htaccess; use a sh404 or similar component to manage the SEF urls.
This model looks quite complicated to me.
It depends what the main goal of this? Its just fetching all articles/users together? But why?
If you are dealing with problem of running one project on multiple Joomla installations I can advise you to put them on single Joomla and than using Virtual Domains (http://extensions.joomla.org/extensions/core-enhancements/multiple-sites/7557) for "copying" the website on other domains. Then you will one database for all your project.
One downside of this is that its mainly suitable for the projects with same component and article structure. Meaning for example local news divided by regions under different domains etc.
For the reference: the solution is really working fast on Joomla 2.5 latest update.