Advanced configurations

The basic set-up let’s you easily set-up a project running your Sylius application. It should give you an environment suitable for testing in combination with Sylius.

In this guide additional tips will be given in order to benefit in a production environment.

Keep sessions between deployments

The default configuration saves PHP sessions into /tmp/sessions. functions in such way that each deployment spins up a new container instance and therefore the temporary folder holding sessions will be gone.

In order to save the PHP sessions on disk, the following steps need to be followed:

  • In add the following under the mount property:
    "/app/sessions": "shared:files/sessions"
  • In the app/config/parameters_platform.php replace the session path:
ini_set('session.save_path', '/app/app/sessions');

Alternatively you can use a php.ini` file in the root of your project:

session.save_path = "/app/app/sessions"

Use Redis for Doctrine caching:

Want to use the metacache, query cache or result cache Symfony and Doctrine have to offer? It comes with a caveat. doesn’t allow you to connect to all your services yet from inside the build hook. The following tutorial will guide you through this and make use of Redis. In the default example Redis is already activated.

  • In your app/config/parameters.yml.dist add:
    metacache_driver: []
    querycache_driver: []
    resultcache_driver: []
    redis_dsn: ~
    redis_host: ~
    redis_port: ~
  • In the app/config/parameters_platform.php file, under the part where the database credentials are set, add:
foreach ($relationships['redis'] as $endpoint) {
    $container->setParameter('metacache_driver', 'redis');
    $container->setParameter('querycache_driver', 'redis');
    $container->setParameter('resultcache_driver', 'redis');

    $container->setParameter('redis_dsn', 'redis://'.$endpoint['host'].':'.$endpoint['port']);
    $container->setParameter('redis_host', $endpoint['host']);
    $container->setParameter('redis_port', $endpoint['port']);


Your Redis connection credentials are now available, which you can also use for the default Symfony cache.

  • In your app/config/config_prod.yml file add:
            type: "%metacache_driver%"
            database: 1
            host: "%redis_host%"
            port: "%redis_port%"
            type: "%querycache_driver%"
            database: 2
            host: "%redis_host%"
            port: "%redis_port%"
            type: "%resultcache_driver%"
            database: 3
            host: "%redis_host%"
            port: "%redis_port%"
  • If you want to empty the cache on deployment, adjust the deploy hook in
    deploy: |
        rm -rf var/cache/*
        php bin/console --env=prod doctrine:cache:clear-metadata
        php bin/console --env=prod doctrine:cache:clear-query
        php bin/console --env=prod doctrine:cache:clear-result
        php bin/console --env=prod doctrine:migrations:migrate --no-interaction

Add default Sylius cronjobs:

Add the example below to your file. This runs these cronjobs every 6 hours.

        spec: '0 */6 * * *'
        cmd: '/usr/bin/flock -n /tmp/ bin/console sylius:remove-expired-carts --env=prod --verbose'
        spec: '0 */6 * * *'
        cmd: '/usr/bin/flock -n /tmp/ bin/console sylius:cancel-unpaid-orders --env=prod --verbose'

Additional tips:

  • can serve gzipped versions of your static assets. Make sure to save your assets in the same folder, but with
    a .gz suffix. The gulp-gzip node package comes very helpful integrating saving of .gz versions of your assets.
  • comes with a New Relic integration.
  • comes with a integration