dimanche 6 novembre 2016

env() issue for several Laravel 5 apps hosted under the same domain

I have 2 Lravel apps, which work under the same domain and stored in subfolders of the domain root:

  • http://ift.tt/2fe3ITw
  • http://ift.tt/2frgYXI

Everything works just fine. But when I call l5-app-2 API endpoint from the first app using CURL, I can see, that laravel env() function returns environment values of the first app (l5-app-1). The workflow is below:

  • the user visits l5-app-1 page
  • this page makes a CURL request to l5-app-2 API endpoint to retrieve some data from another app
  • l5-app-2 responds on this request and tries to fetch some data from the database
  • env() function in l5-app-2 returns database credentials of the l5-app-1 app (!!!???)
  • l5-app-2 throws an exception, because DB credentials are wrong

Anybody knows why environment variables are shared between these 2 apps? Why environment variable are not reset for another php process? Anybody knows how to avoid that?

I really need to host multiple Laravel apps under the same domain. It is not an option for me to use a subdomain for each of them.

Some more configuration details:

I am using XAMPP for dev environment on Windows 8. Apache virtual host looks like:

<VirtualHost *:443>
    ...
    DocumentRoot "F:/dev/xampp/htdocs"
    ServerName www.site.com
    Alias /l5-app-1 "F:/dev/xampp/htdocs/l5-app-1/public"
    Alias /l5-app-2 "F:/dev/xampp/htdocs/l5-app-2/public"
    ...
</VirtualHost>

.htaccess file in /public folder has the line:

RewriteBase /l5-app-1/

I have also defined a special session path to the Laravel config of each application to avoid session conflicts between them (file config/session.php):

'path' => '/l5-app-1', //(the same for 2)

I hope you guys will be able to help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire