Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The State of Symfony in the Cloud

The State of Symfony in the Cloud


Fabien Potencier

December 01, 2016

More Decks by Fabien Potencier

Other Decks in Technology


  1. The State
 of Symfony
 in the Cloud Fabien Potencier @fabpot

  2. None
  3. "The most common way to deploy a project to production

    is to transfer all its files by FTP (or SFTP). [...] the symfony lib/ and data/ directories are linked by svn:externals
  4. Sending the root project directory by FTP is fine for

    the first transfer, but when you need to upload an update of your application, where only a few files have changed, FTP is not ideal.
  5. The solution that is supported by symfony is rsync synchronization

    through an SSH layer. More and more commercial hosts support an SSH tunnel to secure file uploads on their servers...
  6. Don't forget to clear the cache in the production server

    after synchronization.
  7. Code Deployment
 in 2016

  8. Read-Only Filesystems Code Deployment
 in 2016

  9. Read-Only Filesystems Build vs Run Code Deployment
 in 2016

  10. Read-Only Filesystems Build vs Run Isolated and Agnostic Code Deployment

    in 2016
  11. Read-Only Filesystems Build vs Run Isolated and Agnostic Code Deployment

    in 2016
  12. Read-Only Filesystems Build vs Run Isolated and Agnostic Configurable at

    Runtime Code Deployment
 in 2016
  13. Read-Only Filesystems and Symfony

  14. class AppKernel extends Kernel { // ... public function getCacheDir()

    { return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); } public function getLogDir() { return dirname(__DIR__).'/var/logs'; } }
  15. Relative paths in cache Code Deployment
 in 2016

  16. There is a big problem to build a site in

    a temporary directory, warm up the cache for production mode on the build server and then rsyncing it to the production server into another directory.
  17. None
  18. None
  19. None
  20. None
  21. The biggest problem is the usage of dirname which is

    naive per the PHP documentation: "dirname() operates naively on the input string, and is not aware of the actual filesystem, or path components such as "..".")". ... Looking at this issue again, I think there is no easy fix. Using dirname() will indeed work but as noted by @jakzal, the cache dir can be outside of the root dir. In this case, using dirname() won't help.
  22. None
  23. None
  24. None
  25. None
  26. None
  27. Read-only Cache Code Deployment
 in 2016

  28. None
  29. ok so the whole sf2 cache can be warmup from

    now in 1 pass? If you tell me how to accomplish that... I'm very interested!
  30. None
  31. 3.2

  32. 3.3?

  33. var/cache vs var/tmp 3.3?

  34. 3.3? cache:clear vs cache:warmup

  35. Symfony in 2016 Code, Data, and Services

  36. Symfony in 2016 Service Wiring in 2016

  37. Symfony in 2016 Env Vars

  38. Env Vars Code Deployment
 in 2016

  39. None
  40. host: '%env(DATABASE_HOST)%' parameters: env(DATABASE_HOST): localhost

  41. Symfony in 2016 Infrastructure Configuration

  42. Infrastructure Configuration {
 "require": {
 "php": ">=5.5.9",
 "silex/silex": "~2.0",

 "symfony/asset": "~2.8|3.0.*",
  43. None
  44. Infrastructure Configuration {
 "require": {
 "php": ">=5.5.9",
 "silex/silex": "~2.0",

 "symfony/asset": "~2.8|3.0.*", pgsqldb:
 type: postgresql:9.6
 disk: 2048
 type: redis:3.0 runtime:
 - apcu
 - pdo_pgsql
 - redis
 sphinx: "1.3"
 sass: "*"
  45. Git-powered Infrastructure

  46. sensiocloud branch feat-db master

  47. sensiocloud push feat-a

  48. sensiocloud sync -y data

  49. sensiocloud merge feat-db

  50. sensiocloud init

  51. sensiocloud tunnel:open

  52. From development to Production 99.99% SLA on the entire stack

  53. fabien@sensio.cloud Available early 2017