Skip to content

Commit

Permalink
Update to use Symfony 3.3 and env() paramters
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Oct 13, 2017
1 parent 81c73e7 commit 2565be4
Show file tree
Hide file tree
Showing 30 changed files with 252 additions and 346 deletions.
33 changes: 23 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,34 @@
# More details about excluding specific file on your local environment can be found
# in the official GitHub article: https://help.github.com/articles/ignoring-files/

/.web-server-pid
/app/config/parameters.yml
/build/
/phpunit.xml
/var/*
!/var/cache
/var/cache/*
!var/cache/.gitkeep
!/var/logs
/var/logs/*
!var/logs/.gitkeep
!/var/sessions
/var/sessions/*
!var/sessions/.gitkeep
!var/SymfonyRequirements.php
/vendor/
/web/bundles/

.php~
/bin/behat
/bin/phpunit
/app/check.php
/app/SymfonyRequirements.php
/app/cache/
/app/logs/

# Legacy related ignores, that are generated by composer (settings not handled out of the box)
/ezpublish_legacy
/app/config/parameters.yml
/app/bootstrap.php.cache
/doc/docker/entrypoint/*/*.sql
/web/index_treemenu.php
/web/index_rest.php
/web/index_cluster.php
/web/bundles/

/doc/docker/entrypoint/*/*.sql

/web/css/
/web/js/
web/fonts/
Expand All @@ -41,6 +53,7 @@ web/fonts/
/web/share
/web/var
/web/.htaccess

composer.phar
composer.lock
.buildpath
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ RUN composer dump-autoload --optimize

# Next, remove everything we don't want to be copied to next build stage
# Clear cache again so env variables are taken into account on startup
RUN rm -Rf app/logs/* app/cache/*/*
RUN rm -Rf var/logs/* var/cache/*/*

# Looks like we need to keep web/bundles ( like web/bundles/ezstudioui/js/views/ezs-landingpageview.js ) or else
# urls like http://localhost:8080/_ezcombo?/bundles/ezstudioui/js/views/ezs-landingpageview.js&/tpl/handlebars/studiolandingpageconfigview-ez-template.js&/bundles/ezstudioui/js/views/ezs-landingpageconfigview.js&/tpl/handlebars/studiolayoutselectorview-ez-template.js&/bundles/ezstudioui/js/views/ezs-layoutselectorview.js&/tpl/handlebars/studiolandingpageconfigpopupformview-ez-template.js&/bundles/ezstudioui/js/views/forms/ezs-landingpageconfigpopupformview.js&/tpl/handlebars/landingpagecreatorview-ez-template.js&/bundles/ezsystemsformbuilder/js/models/fb-formfield-model.js&/bundles/ezsystemsformbuilder/js/lists/fb-formfields-modellist.js&/bundles/ezsystemsformbuilder/js/models/fb-formpage-model.js&/bundles/ezsystemsformbuilder/js/lists/fb-formpages-modellist.js&/bundles/ezsystemsformbuilder/js/models/fb-form-model.js&/tpl/handlebars/fbbasetabview-ez-template.js&/bundles/ezsystemsformbuilder/js/tabs/fb-base-tabview.js&/tpl/handlebars/fbpanelview-ez-template.js&/bundles/ezsystemsformbuilder/js/panels/fb-panelview.js
# will not work when loading http://localhost:8080/ez
Expand All @@ -34,6 +35,6 @@ ENV SYMFONY_ENV=prod
COPY --from=builder /var/www /var/www

# Fix permissions for www-data
RUN chown -R www-data:www-data app/cache app/logs \
&& find app/cache app/logs -type d -print0 | xargs -0 chmod -R 775 \
&& find app/cache app/logs -type f -print0 | xargs -0 chmod -R 664
RUN chown -R www-data:www-data var web/var \
&& find var web/var -type d -print0 | xargs -0 chmod -R 775 \
&& find var web/var -type f -print0 | xargs -0 chmod -R 664
29 changes: 26 additions & 3 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppKernel extends Kernel
*/
public function registerBundles()
{
$bundles = array(
$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
Expand All @@ -23,7 +23,6 @@ public function registerBundles()
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Tedivm\StashBundle\TedivmStashBundle(),
new Hautelook\TemplatedUriBundle\HautelookTemplatedUriBundle(),
new Liip\ImagineBundle\LiipImagineBundle(),
new FOS\HttpCacheBundle\FOSHttpCacheBundle(),
Expand All @@ -47,7 +46,7 @@ public function registerBundles()
new Bazinga\Bundle\JsTranslationBundle\BazingaJsTranslationBundle(),
new JMS\TranslationBundle\JMSTranslationBundle(),
new AppBundle\AppBundle(),
);
];

switch ($this->getEnvironment()) {
case 'test':
Expand All @@ -61,12 +60,36 @@ public function registerBundles()
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
$bundles[] = new Symfony\Bundle\WebServerBundle\WebServerBundle();
$bundles[] = new Egulias\ListenersDebugCommandBundle\EguliasListenersDebugCommandBundle();
}

return $bundles;
}

public function getRootDir()
{
return __DIR__;
}

public function getCacheDir()
{
if (!empty($_SERVER['SYMFONY_TMP_DIR'])) {
return dirname($_SERVER['SYMFONY_TMP_DIR']) . '/var/cache/' . $this->getEnvironment();
}

return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
}

public function getLogDir()
{
if (!empty($_SERVER['SYMFONY_TMP_DIR'])) {
return dirname($_SERVER['SYMFONY_TMP_DIR']) . '/var/logs';
}

return dirname(__DIR__) . '/var/logs';
}

/**
* Loads the container configuration.
*
Expand Down
20 changes: 0 additions & 20 deletions app/autoload.php

This file was deleted.

10 changes: 10 additions & 0 deletions app/config/cache_pool/cache.memcached.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Reusable service for memcache cache for use in tests/docker/platform.sh
services:
cache.memcached:
parent: cache.adapter.memcached
tags:
- name: cache.pool
clearer: cache.app_clearer
# Example from vendor/symfony/symfony/src/Symfony/Component/Cache/Traits/MemcachedTrait.php:
# memcached://user:pass@localhost?weight=33'
provider: 'memcached://%env(CACHE_DSN)%'
12 changes: 12 additions & 0 deletions app/config/cache_pool/cache.redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Reusable service for redis cache for use in tests/docker/platform.sh
services:
cache.redis:
parent: cache.adapter.redis
tags:
- name: cache.pool
clearer: cache.app_clearer
# Examples from vendor/symfony/symfony/src/Symfony/Component/Cache/Traits/RedisTrait.php:
# redis://localhost:6379
# redis://[email protected]:1234/13
# redis://secret@/var/run/redis.sock/13?persistent_id=4&class=Redis&timeout=3&retry_interval=3
provider: 'redis://%env(CACHE_DSN)%'
7 changes: 0 additions & 7 deletions app/config/cache_pool/singlememcached.yml

This file was deleted.

7 changes: 0 additions & 7 deletions app/config/cache_pool/singleredis.yml

This file was deleted.

62 changes: 19 additions & 43 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,60 +10,37 @@ doctrine:
dbal:
connections:
default:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
user: "%database_user%"
password: "%database_password%"
dbname: "%database_name%"
driver: '%env(DATABASE_DRIVER)%'
host: '%env(DATABASE_HOST)%'
port: '%env(DATABASE_PORT)%'
dbname: '%env(DATABASE_NAME)%'
user: '%env(DATABASE_USER)%'
password: '%env(DATABASE_PASSWORD)%'
charset: UTF8

# Base configuration for Solr, for more options see: https://doc.ez.no/display/EZP/Solr+Search+Engine+Bundle
# Can have several connections used by each eZ Repositories in ezplatform.yml
ez_search_engine_solr:
endpoints:
endpoint0:
dsn: "%solr_dsn%"
core: "%solr_core%"
dsn: '%env(SOLR_DSN)%'
core: '%env(SOLR_CORE)%'
connections:
default:
entry_endpoints:
- endpoint0
mapping:
default: endpoint0

# Stash is used for persistence cache in eZ Repository
# Can have several caches used by different eZ Repositories in ezplatform.yml, must be one per database
stash:
caches:
default:
drivers:
# When using multiple webservers, you must use Memcache or Redis to share the cache
# For single web server Apc, Memcached and Redis will give you better performance under editing load
- FileSystem
inMemory: true
registerDoctrineAdapter: false
# On Windows, using FileSystem, to avoid hitting filesystem limitations
# you need to change the keyHashFunction used to generate cache directories to "crc32"
# FileSystem:
# keyHashFunction: crc32
# Disable tracking of cache values to avoid large disk use when using web profiler
tracking_values: false

framework:
esi: ~
translator: { fallback: '%locale_fallback%' }
secret: '%secret%'
secret: '%env(SYMFONY_SECRET)%'
router:
resource: '%kernel.root_dir%/config/routing.yml'
resource: '%kernel.project_dir%/app/config/routing.yml'
strict_requirements: ~
csrf_protection: ~
form:
csrf_protection:
enabled: true
# Note: changing this will break legacy extensions that rely on the default name to alter AJAX requests
# See https://jira.ez.no/browse/EZP-20783
field_name: ezxform_token
form: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
# Place "eztpl" engine first intentionally if you setup use with legacy bridge.
Expand All @@ -76,13 +53,16 @@ framework:
trusted_hosts: ~
session:
# https://symfony.com/doc/current/reference/configuration/framework.html#handler-id
# handler_id set to null will use default session handler from php.ini
handler_id: ~
handler_id: session.handler.native_file
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
# Note: eZ Publish also allows session name and session cookie configuration to be per SiteAccess, by
# default session name will be set to "eZSESSID{siteaccess_hash}" (unique session name per siteaccess)
# Further reading on sessions: http://doc.ezplatform.com/en/master/guide/sessions/
fragments: ~
http_method_override: true
assets: true
php_errors:
log: true

# Twig Configuration
twig:
Expand All @@ -97,17 +77,13 @@ assetic:
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

# Swiftmailer Configuration
swiftmailer:
transport: '%mailer_transport%'
host: '%mailer_host%'
username: '%mailer_user%'
password: '%mailer_password%'
host: '%env(MAILER_HOST)%'
username: '%env(MAILER_USER)%'
password: '%env(MAILER_PASSWORD)%'
spool: { type: memory }

# FOSHttpCache Configuration
Expand Down
39 changes: 16 additions & 23 deletions app/config/config_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ imports:

framework:
router:
resource: '%kernel.root_dir%/config/routing_dev.yml'
resource: '%kernel.project_dir%/app/config/routing_dev.yml'
strict_requirements: true
profiler: { only_exceptions: false }

Expand All @@ -16,35 +16,28 @@ monolog:
handlers:
main:
type: '%log_type%'
path: '%log_path%'
path: '%env(LOG_PATH)%'
level: debug
channels: ['!event']
console:
type: console
bubble: false
verbosity_levels:
VERBOSITY_VERBOSE: INFO
VERBOSITY_VERY_VERBOSE: DEBUG
channels: ["!doctrine"]
console_very_verbose:
type: console
bubble: false
verbosity_levels:
VERBOSITY_VERBOSE: NOTICE
VERBOSITY_VERY_VERBOSE: NOTICE
VERBOSITY_DEBUG: DEBUG
channels: ["doctrine"]
process_psr_3_messages: false
channels: ['!event', '!doctrine', '!console']
# To follow logs in real time, execute the following command:
# `bin/console server:log -vv`
server_log:
type: server_log
process_psr_3_messages: false
host: 127.0.0.1:9911

# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info

assetic:
use_controller: true
# type: chromephp
# level: info

#swiftmailer:
# delivery_address: [email protected]
# delivery_addresses: ['[email protected]']
7 changes: 2 additions & 5 deletions app/config/config_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ imports:
- { resource: config.yml }
- { resource: ezplatform_prod.yml }

#framework:
# validation:
# cache: apc

#doctrine:
# orm:
# metadata_cache_driver: apc
Expand All @@ -21,7 +17,8 @@ monolog:
handler: nested
nested:
type: '%log_type%'
path: '%log_path%'
path: '%env(LOG_PATH)%'
level: debug
console:
type: console
process_psr_3_messages: false
Loading

0 comments on commit 2565be4

Please sign in to comment.