Skip to content

Commit

Permalink
Improve performance inside the development VM
Browse files Browse the repository at this point in the history
Composer was running really slow inside the VM. The problem was that
the shared folder FS from VirtualBox has speed issues, so after following
some articles (e.g. http://by-examples.net/2014/12/09/symfony2-on-vagrant.html)
seems that the solution is placing the vendors directory outside the shared
folder.

Now AgenDAV reads a new environment variable, COMPOSER_VENDOR_DIR (it's an actual
variable read from Composer) to load vendors from a different path. Note that
the vendors/ directory inside web/ will not be used by the development VM.
  • Loading branch information
jorgelzpz committed Jan 28, 2015
1 parent 0763937 commit 6cc2ee0
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 6 deletions.
3 changes: 1 addition & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Vagrant.configure("2") do |config|

config.vm.box = "trusty64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.box = "ubuntu/trusty64"

config.vm.hostname = "agendav.dev"
config.vm.network "forwarded_port", guest: 80, host: 8080
Expand Down
2 changes: 2 additions & 0 deletions ansible/agendav/settings.php.j2
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ $app['defaults.weekstart'] = 0;
// Logout redirection. Optional
$app['logout.redirection'] = '';

// Put twig cache outside the shared folder
$app['twig.options'] = array('cache' => '/var/cache/twig');
1 change: 1 addition & 0 deletions ansible/apache/agendav
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<Location />
SetEnv ENABLE_AGENDAV_DEVELOPMENT
SetEnv COMPOSER_VENDOR_DIR "/var/agendav-vendors"
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Expand Down
12 changes: 12 additions & 0 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@
file: path=/var/log/agendav state=directory owner=www-data group=vagrant mode=0774
sudo: yes

- name: create twig cache directory
file: path=/var/cache/twig state=directory owner=www-data group=vagrant mode=0774
sudo: yes

- name: create vendors/ directory outside of shared folder
file: path=/var/agendav-vendors state=directory owner=vagrant group=www-data mode=0775
sudo: yes

- name: check if composer is installed
stat: path=/usr/local/bin/composer
register: composer
Expand All @@ -108,12 +116,16 @@
sudo: yes

- name: install composer dependencies
environment:
COMPOSER_VENDOR_DIR: /var/agendav-vendors
command: /usr/local/bin/composer install chdir=/vagrant/web

- name: configure agendav
template: src=agendav/settings.php.j2 dest=/vagrant/web/config/settings.php backup=yes

- name: apply latest schema updates
environment:
COMPOSER_VENDOR_DIR: /var/agendav-vendors
command: /vagrant/bin/agendavcli migrations:migrate --configuration=/vagrant/bin/migrations.yml --no-interaction

- name: change log permissions again
Expand Down
8 changes: 7 additions & 1 deletion bin/agendavcli
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#!/usr/bin/php
<?php

require_once __DIR__ . '/../web/vendor/autoload.php';
$vendor_directory = getenv('COMPOSER_VENDOR_DIR');
if ($vendor_directory === false) {
$vendor_directory =__DIR__ . '/../web/vendor';
}

require_once $vendor_directory . '/autoload.php';

$app = require_once __DIR__ . '/../web/app/app.php';
require __DIR__.'/../web/config/prod.php';

Expand Down
2 changes: 1 addition & 1 deletion web/config/dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$app['http.debug'] = true;

$app->register(new WebProfilerServiceProvider(), [
'profiler.cache_dir' => __DIR__.'/../var/cache/profiler',
'profiler.cache_dir' => '/tmp',
]);

// Enable debug logging
Expand Down
7 changes: 6 additions & 1 deletion web/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

ini_set('display_errors', 0);

require_once __DIR__.'/../vendor/autoload.php';
$vendor_directory = getenv('COMPOSER_VENDOR_DIR');
if ($vendor_directory === false) {
$vendor_directory = __DIR__.'/../vendor';
}

require_once $vendor_directory . '/autoload.php';

$app = require __DIR__.'/../app/app.php';

Expand Down
7 changes: 6 additions & 1 deletion web/public/index_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

use Symfony\Component\Debug\Debug;

require_once __DIR__.'/../vendor/autoload.php';
$vendor_directory = getenv('COMPOSER_VENDOR_DIR');
if ($vendor_directory === false) {
$vendor_directory = __DIR__.'/../vendor';
}

require_once $vendor_directory . '/autoload.php';

Debug::enable();

Expand Down

0 comments on commit 6cc2ee0

Please sign in to comment.