mdamia mdamia - 18 days ago 5
PHP Question

Laravel 5.X one instance multiple app

I am looking to set up one instance of laravel and run multiple apps. Each app would have it's own namespace with custom routes,config, assets, views and its owncomposer.json. All apps will share the same vendor file.
This is what I have done so far.
Created multiple namespaces, and that's how each app directory structure look like

|--app
|--App1
|-- app
|-- Bootstrap
|-- config
|-- database
|-- public
|-- resources
|-- storage
|-- ..
|-- composer.json
|-- App2
|--..
|--vendor


to resolve the vendor dependencies I change the vendor folder location in composer.json likes this

"config": {
"preferred-install": "dist",
"vendor-dir":"../vendor"
}


I also updated the vendor path in autoload.php to point to the correct location.

The env where I am setting up this project, also runs other laravel projects. So all the ingredients are there(htaccess,, vhosts, ....).

When I ran composer dump-autoload, everything loads I get no errors. When I navigate to my route, I get a blank page.
App debug is set to true.

Is my approach to set up laravel in this fashion correct? if so where did I go wrong or what am I doing wrong.

Thanks a lot in advance.

After I got a little hint from the comment below, I was able to make the set up works.
1 - Make sure storage permission is set to 775 writeable.
2 - Make sure you have created .env file. In my case had to create it, did transfer over.

my vhosts

<VirtualHost *:80>
ServerName app1.server.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/tenants/app1/public
<Directory /var/www/tenants/app1/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


<VirtualHost *:80>
ServerName app2.server.local
ServerAdmin webmaster@localhost
DocumentRoot /var/www/tenants/app2/public
<Directory /var/www/tenants/app2/public/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Hope this help anyone looking to set up one laravel instance and run multiple apps.

Answer

Tim's comment pointed out what I was missing. I changed the storage folder permission to 775. I added .env file. and Booya, I have multiple apps with a single laravel instance. It works like a charm.

Comments