I am currently working on a Laravel 5.1 project which involves a public section and a admin section. When googling around the issue I was having, I came across this stack post managing user role log in. Where the first post recommends.
Admin and Users in the same laravel app is a bad idea simply because the app will share the same session and storage information. There will be a myriad of egde cases that will cause information to bleed through any logic "walls" you set up and you'll end up spending way too much time patching those bleeds. What you really want to do is set up separate laravel applications for each: admin.project.com & project.com. That way you get two separate sessions and storage. All you need to do is ensure that the databases you need are setup in both database.php config files. You can even host BOTH projects on the same server with separate deployments, listening to different ports. TRUST ME this is the best way to go.
Could someone explain in detail how it could be done? I mean how should I set up my project. I know It is easy for them to share the same DB and setting up that would easy. First question, how can I have URLs admin.mysite.com as my admin section and www.mysite.com as my public section for my 2 apps Also how to set it up in Azure as a web app? I got my one app I currently have working on Azure ( no 5.1 guides on the internet, got it deploying somehow).
So could someone explain in detail how the project setup should like and how it should be done? Could not find guides for Laravel 5.1 and since 5.1 setup is different from 5 and 4.* I'm not sure how to continue.
Per your description, it seems you need to deploy 2 apps with custom domains. If so, I think to deploy your admin and user apps separately on 2 Azure Web Apps services. Which is benefit for management, deployment and scaling for each side of your applications. To configure subdomains to your site, you can refer to Azure Websites and wildcard domains and Mapping a custom subdomain to an Azure Web App (Website).
If you insist on deploy 2 apps on a single Azure Web Apps Service, you can try it with URL rewriting in IIS Web.config, E.g.
<rule name="RewriteRequestsAdmin" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^admin\.XXXX\.com$"/>
</conditions>
<action type="Rewrite" url="AdminApp/public/index.php/{R:0}" />
</rule>
<rule name="RewriteRequestsUser" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
</conditions>
<action type="Rewrite" url="UserApp/public/index.php/{R:0}" />
</rule>
</rules>
To deploy your local laravel project to Azure Web Apps, you can use Git or FTP tools, please refer to Create a PHP-MySQL web app in Azure App Service and deploy using Git. But by default, the dependence folder vendor
and composer files will not be deployed on Azure with project, so we have to login KUDU console site of your Azure Web Apps to install the dependences. You can install composer in site extensions tab of your KUDU console site which the URL should be https://<your_site_name>.scm.azurewebsites.net/SiteExtensions/#gallery
then run command composer install
in your app root directory.
Additionally, you can simply leverage cmdlet on your KUDU console site, which URL should be https://<your-website-name>.scm.azurewebsites.net/DebugConsole
, run the following commands:
cd site\wwwroot
curl -sS https://getcomposer.org/installer | php
php composer.phar install
For deployment laravel on Azure, you can refer to the answer of laravel 5.1 on windows azure web application for more information.