3

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.

Volomike
  • 23,743
  • 21
  • 113
  • 209
  • IMHO there's no real benefit from doing that and you are asking for troubles at some point, as at some point you simply step on issues caused by i.e. upgrade, not to mention dependencies. Unless on your planet 1MB of HDD space costs you leg and kidney, you will waste more than you gain. – Marcin Orlowski Oct 14 '16 at 18:35

2 Answers2

3

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.

Erik Berkun-Drevnig
  • 2,306
  • 23
  • 38
0

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...

Jorge Y. C. Rodriguez
  • 3,394
  • 5
  • 38
  • 61