diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..99505e60de2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,27 @@ +[submodule "vagrant/modules/stdlib"] + path = vagrant/modules/stdlib + url = git@github.com:puppetlabs/puppetlabs-stdlib.git +[submodule "vagrant/modules/puppi"] + path = vagrant/modules/puppi + url = git@github.com:example42/puppi.git +[submodule "vagrant/modules/apache"] + path = vagrant/modules/apache + url = git@github.com:example42/puppet-apache.git +[submodule "vagrant/modules/apt"] + path = vagrant/modules/apt + url = git@github.com:puppetlabs/puppetlabs-apt.git +[submodule "vagrant/modules/composer"] + path = vagrant/modules/composer + url = git@github.com:vagrantee/puppet-composer.git +[submodule "vagrant/modules/mysql"] + path = vagrant/modules/mysql + url = git@github.com:puppetlabs/puppetlabs-mysql.git +[submodule "vagrant/modules/php"] + path = vagrant/modules/php + url = git@github.com:example42/puppet-php.git +[submodule "vagrant/modules/puphpet"] + path = vagrant/modules/puphpet + url = git@github.com:puphpet/puppet-puphpet.git +[submodule "vagrant/modules/xdebug"] + path = vagrant/modules/xdebug + url = git@github.com:puphpet/puphpet-xdebug.git diff --git a/app/AppKernel.php b/app/AppKernel.php index 3cffcf1cf46..e2e35c8e322 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -112,4 +112,22 @@ public function registerContainerConfiguration(LoaderInterface $loader) $loader->load($file); } } + + public function getCacheDir() + { + if (in_array($this->environment, array('dev', 'test')) && is_dir('/dev/shm')) { + return '/dev/shm/sylius/cache/' . $this->environment; + } + + return parent::getCacheDir(); + } + + public function getLogDir() + { + if (in_array($this->environment, array('dev', 'test')) && is_dir('/dev/shm')) { + return '/dev/shm/sylius/logs'; + } + + return parent::getLogDir(); + } } diff --git a/app/SymfonyRequirements.php b/app/SymfonyRequirements.php index 321f894c499..ccfc30489e6 100644 --- a/app/SymfonyRequirements.php +++ b/app/SymfonyRequirements.php @@ -560,6 +560,14 @@ function_exists('simplexml_import_dom'), 'Install PHP 5.4.11 or newer if your project uses the logout handler from the Symfony Security Component.' ); + $this->addRecommendation( + (version_compare($installedPhpVersion, '5.3.18', '>=') && version_compare($installedPhpVersion, '5.4.0', '<')) + || + version_compare($installedPhpVersion, '5.4.8', '>='), + 'You should use PHP 5.3.18+ or PHP 5.4.8+ to always get nice error messages for fatal errors in the development environment due to PHP bug #61767/#60909', + 'Install PHP 5.3.18+ or PHP 5.4.8+ if you want nice error messages for all fatal errors in the development environment.' + ); + if (null !== $pcreVersion) { $this->addRecommendation( $pcreVersion >= 8.0, @@ -640,6 +648,8 @@ class_exists('Locale'), || (extension_loaded('apc') && ini_get('apc.enabled')) || + (extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable')) + || (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) || (extension_loaded('xcache') && ini_get('xcache.cacher')) diff --git a/vagrant/.gitignore b/vagrant/.gitignore new file mode 100644 index 00000000000..c1a0118f589 --- /dev/null +++ b/vagrant/.gitignore @@ -0,0 +1 @@ +/.vagrant/ diff --git a/vagrant/README.md b/vagrant/README.md index c5579e8c93c..b7fb17c19f9 100644 --- a/vagrant/README.md +++ b/vagrant/README.md @@ -1,28 +1,35 @@ -# Getting started using Vagrant +# Description +This configuration includes following software: -## You will need: +* PHP 5.4.19 +* MySQL 5.5.32 +* GIT 1.7.9.5 +* Apache 2.2.22 +* Vim +* MC (Midnight commander) +* Curl +* Xdebug +* Composer - * Git 1.6+ - * NFS (MacOS works OOB, on Debian based linux distributions install **nfs-kernel-server** package) - * [Vagrant](http://vagrantup.com) +# Usage -## Get the code +First you need to install git submodules. Go to your project root folder and execute following commands: +``` +$ git submodule init +$ git submodule update +``` - git clone git://github.com/Sylius/Sylius.git - cd Sylius/vagrant - vagrant up +Now you are ready to run -Now everything is getting prepared. -In the meantime you can optionally add an entry to your `/etc/hosts` file like so: +``` +$ cd vagrant +$ vagrant up +``` - 172.33.33.33 sylius.local +While waiting for the vagrant to stand up you should add an entry into /etc/hosts file at host machine. -## Access by web browser +``` +10.0.0.200 sylius.dev +``` -If you have added the entry to `/etc/hosts` you should be able to access the Sylius like this: - - - -Otherwise you can also use the IP address: - - +From now you should be able to access your sylius project at host machine under http://sylius.dev/ address. diff --git a/vagrant/Vagrantfile b/vagrant/Vagrantfile index 0b451e55b33..c8698e5c53e 100644 --- a/vagrant/Vagrantfile +++ b/vagrant/Vagrantfile @@ -1,33 +1,23 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : +Vagrant.configure("2") do |config| + config.vm.box = "precise64" + config.vm.box_url = "http://files.vagrantup.com/precise64.box" -Vagrant::Config.run do |config| - # All Vagrant configuration is done here. The most common configuration - # options are documented and commented below. For a complete reference, - # please see the online documentation at vagrantup.com. + config.vm.network :private_network, ip: "10.0.0.200" + config.ssh.forward_agent = true - # Every Vagrant virtual environment requires a box to build off of. - config.vm.box = "precise32" - config.vm.host_name = "sylius" - - # The url from where the 'config.vm.box' box will be fetched if it - # doesn't already exist on the user's system. - config.vm.box_url = "http://files.vagrantup.com/precise32.box" - - config.vm.network :hostonly, "172.33.33.33" - config.vm.share_folder "v-root", "/mnt/sylius", ".." , :nfs => true - - # Whithout this symlinks can't be created on the shared folder. - config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"] + config.vm.provider :virtualbox do |v| + v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + v.customize ["modifyvm", :id, "--memory", 1024] + v.customize ["modifyvm", :id, "--name", "sylius"] + end - # Chef solo configuration. - config.vm.provision :chef_solo do |chef| - chef.cookbooks_path = "./" - # Chef debug level, start vagrant like this to debug: - # $ CHEF_LOG_LEVEL=debug vagrant - chef.log_level = ENV['CHEF_LOG'] || "info" + nfs_setting = RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /linux/ + config.vm.synced_folder "./../", "/var/www/sylius", id: "vagrant-root" , :nfs => nfs_setting + config.vm.provision :shell, :inline => "sudo apt-get update" - # Chef recipes. - chef.add_recipe("cookbook") + config.vm.provision :puppet do |puppet| + puppet.manifests_path = "manifests" + puppet.module_path = "modules" + puppet.options = ['--verbose'] end end diff --git a/vagrant/cookbook/recipes/default.rb b/vagrant/cookbook/recipes/default.rb deleted file mode 100644 index c7ff317e39a..00000000000 --- a/vagrant/cookbook/recipes/default.rb +++ /dev/null @@ -1,89 +0,0 @@ -# Run apt-get update to create the stamp file. -execute "apt-get-update" do - command "apt-get update" - ignore_failure true - not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end -end - -# For other recipes to call to force an update. -execute "apt-get update" do - command "apt-get update" - ignore_failure true - action :nothing -end - -# Provides /var/lib/apt/periodic/update-success-stamp on apt-get update. -package "update-notifier-common" do - notifies :run, resources(:execute => "apt-get-update"), :immediately -end - -execute "apt-get-update-periodic" do - command "apt-get update" - ignore_failure true - only_if do - File.exists?('/var/lib/apt/periodic/update-success-stamp') && - File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400 - end -end - -# Install the software we need. -%w( -curl -apache2 -libapache2-mod-php5 -git -php5-cli -php5-curl -php5-gd -php5-sqlite -php5-mysql -php5-intl -php-apc -).each { | pkg | package pkg } - -template "/etc/apache2/sites-enabled/vhost.conf" do - user "root" - mode "0644" - source "vhost.conf.erb" - notifies :reload, "service[apache2]" -end - -service "apache2" do - supports :restart => true, :reload => true, :status => true - action [ :enable, :start ] -end - -execute "check if short_open_tag is Off in /etc/php5/apache2/php.ini?" do - user "root" - not_if "grep 'short_open_tag = Off' /etc/php5/apache2/php.ini" - command "sed -i 's/short_open_tag = On/short_open_tag = Off/g' /etc/php5/apache2/php.ini" -end - -execute "check if short_open_tag is Off in /etc/php5/cli/php.ini?" do - user "root" - not_if "grep 'short_open_tag = Off' /etc/php5/cli/php.ini" - command "sed -i 's/short_open_tag = On/short_open_tag = Off/g' /etc/php5/cli/php.ini" -end - -execute "check if date.timezone is UTC in /etc/php5/apache2/php.ini?" do - user "root" - not_if "grep '^date.timezone = UTC' /etc/php5/apache2/php.ini" - command "sed -i 's/;date.timezone =.*/date.timezone = UTC/g' /etc/php5/apache2/php.ini" -end - -execute "check if date.timezone is UTC in /etc/php5/cli/php.ini?" do - user "root" - not_if "grep '^date.timezone = UTC' /etc/php5/cli/php.ini" - command "sed -i 's/;date.timezone =.*/date.timezone = UTC/g' /etc/php5/cli/php.ini" -end - -bash "Running composer install and preparing the Sylius repository" do - not_if "test -e /vagrant/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/public" - user "vagrant" - cwd "/mnt/sylius" - code <<-EOH - set -e - curl -s https://getcomposer.org/installer | php - COMPOSER_VENDOR_DIR="/var/tmp/vendor" php composer.phar install --dev --prefer-dist --no-scripts - EOH -end diff --git a/vagrant/cookbook/templates/default/vhost.conf.erb b/vagrant/cookbook/templates/default/vhost.conf.erb deleted file mode 100644 index 18f8b387ac4..00000000000 --- a/vagrant/cookbook/templates/default/vhost.conf.erb +++ /dev/null @@ -1,11 +0,0 @@ -User vagrant -Group vagrant - - - Servername sylius.local - Serveralias 172.33.33.33 - DocumentRoot /mnt/sylius/web - - AllowOverride All - - diff --git a/vagrant/manifests/default.pp b/vagrant/manifests/default.pp new file mode 100644 index 00000000000..7aa47100ef3 --- /dev/null +++ b/vagrant/manifests/default.pp @@ -0,0 +1,170 @@ +$host_name = "sylius.dev" +$db_name = "sylius" +$db_name_dev = "${db_name}-dev" +$db_name_tst = "${db_name}-tst" + +group { 'puppet': ensure => present } +Exec { path => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ] } +File { owner => 0, group => 0, mode => 0644 } + +file { "/dev/shm/sylius": + ensure => directory, + purge => true, + force => true, + owner => vagrant, + group => vagrant +} + +file { "/var/lock/apache2": + ensure => directory, + owner => vagrant +} + +exec { "ApacheUserChange" : + command => "sed -i 's/export APACHE_RUN_USER=.*/export APACHE_RUN_USER=vagrant/ ; s/export APACHE_RUN_GROUP=.*/export APACHE_RUN_GROUP=vagrant/' /etc/apache2/envvars", + require => [ Package["apache"], File["/var/lock/apache2"] ], + notify => Service['apache'], +} + +class {'apt': + always_apt_update => true, +} + +Class['::apt::update'] -> Package <| + title != 'python-software-properties' +and title != 'software-properties-common' +|> + + apt::key { '4F4EA0AAE5267A6C': } + +apt::ppa { 'ppa:ondrej/php5-oldstable': + require => Apt::Key['4F4EA0AAE5267A6C'] +} + +package { [ + 'build-essential', + 'vim', + 'curl', + 'git-core', + 'mc' + ]: + ensure => 'installed', +} + +class { 'apache': } + +apache::dotconf { 'custom': + content => 'EnableSendfile Off', +} + +apache::module { 'rewrite': } + +apache::vhost { "${host_name}": + server_name => "${host_name}", + serveraliases => [ + "www.${host_name}" + ], + docroot => "/var/www/sylius/web/", + port => '80', + env_variables => [ +], + priority => '1', +} + +class { 'php': + service => 'apache', + service_autorestart => false, + module_prefix => '', +} + +php::module { 'php5-mysql': } +php::module { 'php5-cli': } +php::module { 'php5-curl': } +php::module { 'php5-intl': } +php::module { 'php5-mcrypt': } +php::module { 'php5-gd': } +php::module { 'php-apc': } + +class { 'php::devel': + require => Class['php'], +} + +class { 'php::pear': + require => Class['php'], +} + +php::pear::module { 'PHPUnit': + repository => 'pear.phpunit.de', + use_package => 'no', + require => Class['php::pear'] +} + +php::pecl::module { 'mongo': + use_package => "no", +} + +class { 'xdebug': + service => 'apache', +} + +class { 'composer': + require => Package['php5', 'curl'], +} + +puphpet::ini { 'xdebug': + value => [ + 'xdebug.default_enable = 1', + 'xdebug.remote_autostart = 0', + 'xdebug.remote_connect_back = 1', + 'xdebug.remote_enable = 1', + 'xdebug.remote_handler = "dbgp"', + 'xdebug.remote_port = 9000' + ], + ini => '/etc/php5/conf.d/sylius_xdebug.ini', + notify => Service['apache'], + require => Class['php'], +} + +puphpet::ini { 'mongo': + value => [ + 'extension=mongo.so', + ], + ini => '/etc/php5/conf.d/sylius_mongo.ini', + notify => Service['apache'], + require => Class['php'], +} + +puphpet::ini { 'custom': + value => [ + 'date.timezone = "UTC"', + 'display_errors = On', + 'error_reporting = -1', + 'short_open_tag = 0', + 'xdebug.max_nesting_level = 1000' + ], + ini => '/etc/php5/conf.d/sylius_custom.ini', + notify => Service['apache'], + require => Class['php'], +} + +class { 'mysql::server': + override_options => { 'root_password' => '', }, +} + +database{ "sylius": + ensure => present, + charset => 'utf8', + require => Class['mysql::server'], +} + +database{ "sylius_dev": + ensure => present, + charset => 'utf8', + require => Class['mysql::server'], +} + +database{ "sylius_test": + ensure => present, + charset => 'utf8', + require => Class['mysql::server'], +} \ No newline at end of file diff --git a/vagrant/modules/apache b/vagrant/modules/apache new file mode 160000 index 00000000000..5c4b1ccfd42 --- /dev/null +++ b/vagrant/modules/apache @@ -0,0 +1 @@ +Subproject commit 5c4b1ccfd42d691567feb0ec2ce5fe0e215940f4 diff --git a/vagrant/modules/apt b/vagrant/modules/apt new file mode 160000 index 00000000000..3e3de6ee924 --- /dev/null +++ b/vagrant/modules/apt @@ -0,0 +1 @@ +Subproject commit 3e3de6ee924ea75463e9df4ffdb5712c0e145403 diff --git a/vagrant/modules/composer b/vagrant/modules/composer new file mode 160000 index 00000000000..527ee1dc4b3 --- /dev/null +++ b/vagrant/modules/composer @@ -0,0 +1 @@ +Subproject commit 527ee1dc4b33ce262ad1484ebfde334b6dcba3f5 diff --git a/vagrant/modules/mysql b/vagrant/modules/mysql new file mode 160000 index 00000000000..e0c4434815b --- /dev/null +++ b/vagrant/modules/mysql @@ -0,0 +1 @@ +Subproject commit e0c4434815bbe0dc6851d9c40c1ba8cd84c73942 diff --git a/vagrant/modules/php b/vagrant/modules/php new file mode 160000 index 00000000000..b8f2e3f3dbe --- /dev/null +++ b/vagrant/modules/php @@ -0,0 +1 @@ +Subproject commit b8f2e3f3dbeefa2e42eb5cbd35a2576cd11b14e3 diff --git a/vagrant/modules/puphpet b/vagrant/modules/puphpet new file mode 160000 index 00000000000..b98b7e1c567 --- /dev/null +++ b/vagrant/modules/puphpet @@ -0,0 +1 @@ +Subproject commit b98b7e1c5679628d0a9811c568f7bb4fdda3f878 diff --git a/vagrant/modules/puppi b/vagrant/modules/puppi new file mode 160000 index 00000000000..c03f5291b46 --- /dev/null +++ b/vagrant/modules/puppi @@ -0,0 +1 @@ +Subproject commit c03f5291b468a25869f3787819c9ea76de91b5ee diff --git a/vagrant/modules/stdlib b/vagrant/modules/stdlib new file mode 160000 index 00000000000..d60d872c1ab --- /dev/null +++ b/vagrant/modules/stdlib @@ -0,0 +1 @@ +Subproject commit d60d872c1ab676298824dad863237fa390e1ddd6 diff --git a/vagrant/modules/xdebug b/vagrant/modules/xdebug new file mode 160000 index 00000000000..b15bbabf6ff --- /dev/null +++ b/vagrant/modules/xdebug @@ -0,0 +1 @@ +Subproject commit b15bbabf6ffab5b90a269d9b83834b825cc956d1 diff --git a/web/app_dev.php b/web/app_dev.php index d31ff24a81c..550e6b91edc 100644 --- a/web/app_dev.php +++ b/web/app_dev.php @@ -20,6 +20,7 @@ '127.0.0.1', '172.33.33.1', '::1', + '10.0.0.1' ))) { header('HTTP/1.0 403 Forbidden'); exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');