I want to build Laravel CMS with following requirements:
Admin (manage all sites/database).
Multi-sites (running on sub-domains, manage own database) each with API access.
Same Codebase (can be replicated if needed).
Same Database with different data for each site.
Can you please let me know how to setup this environment using Laravel 5.4.
Thanks.
This project has been finished now. So posting my own solution for the question.
Following are points to take care:
I've used Laravel 5.4 (later upgraded to 5.5).
For multi tenancy used Landlord extension for Laravel.
Server is configured to listen for wild-card sub-domains.
Each site is running on sub-domain.
Using single database with site-id (tenant-id) under each DB table.
Whenever server gets request, sub-domain is matched with tenant id in the middleware & load all the records for that tenant only.
I've hope this might help someone else.
For build a Laravel CMS with following requirements you need use:
You can set an Admin Role with policies and gates or uses entrust
For Multi-sites, You can used something like https://github.com/hyn/multi-tenant, so If you use multitenant you can
Multi-sites (running on sub-domains, manage own database) each with
API access. Same Codebase (can be replicated if needed). Same
Database with different data for each site.
For config subdomain you can read the official documentation https://laravel.com/docs/5.4/routing#route-group-sub-domain-routing
Related
Yes, I know it looks like an old question but still unclear.
I have two different Laravel applications and both have their separate tables. On my local system, I put both of them as subdomain domain(virtual host). Both of them are working fine.
What I want is that whenever a user logged in to either of the subdomains then the user should automatically be authenticated to another subdomain. So I don't need to login into my subdomain separately or again and again.
Some people suggest the following solution.
use the identical setup for app key, session.php, database, and use the database as a driver for the session.
use a third domain as the main domain(or subdomain like auth.example.com) and implement SSO with Laravel.
use passport and create the main domain for the oAuth server to provide tokens.
use Redis or Memcached as a session driver to persistent user authentication.
prefix the table(for second app) with some specific string(i.e app_2) and use single database(i.e database merge)
Real use case:-
One Laravel application handle all banking related feature so the subdomain will be banking.example.com
One Laravel application handle all accounting related feature so the subdomain will be accounting.example.com
I am a little bit confused now. Currently, both application is built using blade template engine for now but in future, the frontend may be in React or Angular. As of now, I can go with the Laravel Blade template engine.
Can someone help me with how can I achieve a single login system and persistent user login and also sync user information across main and subdomains in Laravel fashion?
I am using Laravel 5.4 with having Laravel Voyager Installed.
The main requirements of the project are to have the multi-tenant domain based application i.e. app.com and {client}.app.com
I have been trying to load configurations based on a subdomain and will act subdomain as the client code
which worked fine on localhost but while I am pushing changes to live server things are not working
As a beginner in this scope, I am not sure how thing will work on the live environment, in terms of domain redirection and setting up options in middleware, or mainly how wildcard subdomain would work in laravel's subdomain routing
You can use this package: https://github.com/hyn/multi-tenant
I've used this many times and can confirm it works extremely well. As an added bonus, there's a very detailed tutorial you can use to get going here: https://laravel-tenancy.com/docs/hyn/5.x/full-featured-tutorial
I want to archive this username.mydomain.com for each new user register with application and each user has its own database.
Its actually inventory application developed in codeigniter, so user registration will be only done by admin.
One application installation for all sub domain(usersname) should points to same server directory, later application will select database according to subdomain so how can i archive this.
In order to achieve what you want, is to follow the following steps:
DNS Configuration
Apache Configuration
Testing out your server configuration
Setting up CodeIgniter
Creating controllers & Views
Extending created controllers
All of the steps are nicely detailed in Atchyut Sekhar's article on tutsplus.com # https://code.tutsplus.com/tutorials/basecamp-style-subdomains-with-codeigniter--net-16330
Hope that helps!
Best,
-Rush
I am creating a cloud based application in laravel/php.
I have a functionality where user can have their website at user.myapp.com and it works (with subdomain and model binding).
I now want to go one step further, and allow users to add their own custom domain names. So their website will be reachable at user-domain.com rather than (or as well as) user.myapp.com.
I want to understand how to do this. I'm using Laravel framework which is based on php and apache.
What kind of server do I need? Can I use shared hosting?
What configs do I need to do in order for this to work?
What DNS record the user must create to put things together?
You can do this with any kind of server. You can make a route that is caught by any domain and in the controller of this route, you can query the database to know what website should be displayed for that domain.
You can get the domain name of the current request using app('request')->root();
I am working on a SaaS application. We take Shopify / Magento Go etc as reference.
I used CodeIgniter PHP framework.
SaaS Methodology - Multiple database, single code-base
Our SaaS architecture is as follows:
when a customer signup a database is build with his name and contain his specific databases.
when a customer signup he get a sub-domain (Ex: test1.example.com)
The customer can add his own domain that points to the system defined sub-domain. (Ex: test1.example.com to www.mydomain.com )
How to achieve this functionality?
For this you have to go through few configuration options.
Configure DNS: Create sub-domain with *. (ask you host)
You have to configure apache or .htaccess to point all requests coming to your domain point to same directory.
Database Setting: Try to learn how to use multiple database in codeigniter.
That's all. Enjoy!
I think that you should look for the term: " codeigniter multi Tennant app " and as said before, managing too many database isn't a solution!
You can achive proposed SAAS application this way,
There will be 1 database for application itself, and another N number of databases for clients, each new client will have new database.
Allow signup to your clients by asking basic details + subdomain to choose like blogspot do, subdomains taken by existing clients wont be allowed to reuse
When client signup successfully, one separate DB will be created and they will landed to their dashboard. Here one DB server will be fine but should have enough space and other parameter set to handle multiple databases.
Now dahsboard onwards, user will able to see list of functionality to use along with some predefined set of content that will be shared between user and loaded from "app DB". Whatever they do add will goes to their own independent DB
Here codebase will be deployed at one code server and main domain will be mapped to that so login/singup etc will be happen here and user's identification will happen at login level.
App DB: This DB will be responsible to store app level master data, i.e. Client's profile + login details, other admin related stuff which they meant to share to their clients. In case of shopify kind of app, themes, layout, templates can be master stuff that will store into this DB.
User DB: Only user's created, added content and its sub content should be stored. Whatever we can call user's ownership should be stored here.
Note: If its paid service, then you can use good payment gateway like stripe or chargebee to manage all your plans, subscriptions, email notification, dunning, payments log, payment success/failure, payment invoices.
WRT to subdomain and custom domain concept, you can do this using virtual hosting mechanism, you can do with apache as well as nginx server.
- Subdomain: Create config files as per server, put on proper place and any created subdomain will bind to particular pysical virtual directory
- Customdomain: Can create physical directory same as subdomain along with config files but in this case, you will need to ask your client to do DNS binding with our IP addess
In both this case when request comes to our server, server will check if config file and physical directory available tp hit then it will redirect user to destiny forlder.