Volomike
Volomike

Reputation: 24886

How can I have one Laravel PHP install with multiple projects?

I noticed that Laravel 5.3 takes about 41MB on average of disk space per project.

Is there a tidy way to configure things so that Laravel is installed once on my PHP server (which is dedicated to Laravel-only stuff) and then have multiple projects (some as separate domains, some as subdirs) use that same Laravel instance?

So for instance, I could have /usr/share/laravel and put everything in there, but then in /var/www, I could put each of my domains (/var/www/test1.com, /var/www/test2.com) and subfolders on domains (/var/www/test1.com/project2) and then they would all utilize the same /usr/share/laravel.

Upvotes: 3

Views: 1054

Answers (2)

Erik Berkun-Drevnig
Erik Berkun-Drevnig

Reputation: 2356

You could use symlinks, I've never tried this but I guess it would involve creating separate directories for each application then creating symlinks to a shared vendor directory (which includes Laravel).

This would allow you to separately version control all the application specific files but share the dependencies. Watch out though, if your composer.json files have differing versions listed you might run into trouble.

Upvotes: 3

Jorge Y. C. Rodriguez
Jorge Y. C. Rodriguez

Reputation: 3449

Well the solution I did the last time I tried this it was bit different. For any means I think it is a good one or the best one. but it has worked so far:

  • First all domains loads the same laravel project
  • customize route service provider

So first the changes to the RouteServiceProvider:

public function map(Router $router)
{
       if (strstr(Request::getHost(), 'domain_one')) {
            $router->group([
                'namespace' => $this->namespace,
                'middleware' => ['default_middle_wares'],
            ], function ($router) {
                require app_path('Http/Routes/domain_one.php');
            });
        }

        if (strstr(Request::getHost(), 'domain_two')) {
            $router->group([
                'namespace' => $this->namespace,
                'middleware' => ['default_middle_wares'],
            ], function ($router) {
                require app_path('Http/Routes/domain_two.php');
            });
        }
}

After create the route files. and it should work...

Upvotes: 0

Related Questions