too many limitations • Only one connection at a time • No HTTP-2 support • No SSL • Does not re-read env vars if they change • Needs some tweaks to make it work with Symfony (special router) • …
• Binary with no dependencies, not even PHP No global Composer changes • Does more than just the Cloud • symfony security:check without calls to security.symfony.com • symfony new [--demo] [--full] ... to create new Symfony projects • and … https://symfony.com/cloud/download
PHP-FPM whenever possible fallbacks to PHP-CGI/php -S (on Windows for instance) • HTTP-2 support out of the box • HTTP Link/pre-load/push support • Works with any PHP project Use it for plain HTML websites, Symfony ones, Laravel, Drupal, Magento, … • Fire and forget • Great developer experience…
Detect the PHP version to use for this directory $ symfony server:start Algorithm (current directory and up) 1/ .php-version? 2/ .symfony.cloud.yaml? 3/ $PATH
Europe/Paris # Create a php.ini file at the project's directory $ cat php.ini [Date] date.timezone = Europe/Lisbon $ symfony php -r "echo ini_get('date.timezone');" Europe/Lisbon # Works with the web server as well
copy named php $ cd ~/.symfony/bin/ && cp symfony php # Running php now runs the symfony wrapper! # Works with other PHP binaries $ cd ~/.symfony/bin/ && cp symfony pecl $ cd ~/.symfony/bin/ && cp symfony php-fpm $ cd ~/.symfony/bin/ && cp symfony php-config Want to drink the Kool-Aid?
ls ~/.symfony/certs default.p12 rootCA-key.pem rootCA.pem +Creates a local Certificate Authority +Registers it on your system trust store +Registers it on Firefox +Creates a default certificate for localhost/127.0.0.1/...
domain name Think sub-domains like lisbon2018.symfony.com vs paris2019.symfony.com • No need to remember the ports ports can change, is it 8000 or 8001? • Stable endpoint across machines Think oauth2 redirect URL for instance • Use “regular” ports: 80 for HTTP and 443 for HTTPS • More similar to the production settings
to a directory $ symfony proxy:domain:attach symfony.com --dir=~/Code/symfony.com # Start the web server if needed $ symfony server:start -d # Done! https://symfony.com.wip/ is now an “alias” for https://127.0.0.1:8xxx/
symfony run -d yarn encore dev --watch $ symfony server:log $ symfony server:status Web server listening on https://127.0.0.1:8001 Command "/usr/local/bin/yarn encore dev --watch" running with PID 93398 $ symfony server:stop command logs stops the web server and the commands
deploy to prod $ symfony project:init # Deploy a cluster of containers PHP, services like DB, TLS, ... for the master branch/production env $ symfony deploy # Make it live $ symfony domain:attach demo.com ENV=prod DEBUG=false
Git branch for the code # Deploy a new cluster of containers # Copy data (DB, files, ...) byte to byte $ symfony env:create some-bug # Open the new deployed URL # Exact copy of production $ symfony open:remote # Debug logs $ symfony log # Or switch to dev/debug with $ symfony debug Exact copy of production ENV=prod DEBUG=false
domain for fun $ symfony proxy:domain:attach demo.com # Run the local web server $ symfony server:start -d # Open the local website $ symfony open:local ENV=dev DEBUG=true
work? Environment variables FTW! + The local web server detects the tunnel + It exposes the services as env vars in PHP-FPM + Symfony and SymfonyCloud share the same convention + Symfony reads the env vars + You win!
a safe isolated environment Local Web prod DB DATABASE_URL=postgres://127.0.0.1:30002/main symfony tunnel:open 2 some-bug some-bug Web DB symfony env:create Duplicate infra/data Create a local Git branch 1
a safe isolated environment Local Web prod DB DATABASE_URL=postgres://127.0.0.1:30002/main symfony tunnel:open 2 some-bug some-bug Web symfony server:start 3 some-bug some-bug Web DB symfony env:create Duplicate infra/data Create a local Git branch 1
a safe isolated environment Local Web prod DB DATABASE_URL=postgres://127.0.0.1:30002/main symfony tunnel:open 2 some-bug some-bug Web symfony server:start 3 some-bug some-bug Web DB symfony env:create Duplicate infra/data Create a local Git branch 1 symfony env:sync
# Update the DB schema # Change/Add some services $ git commit ... # Deploy on the remote env $ symfony deploy # Check that everything is fine $ symfony open:remote # If the fix takes some time # Sync back the data from prod $ symfony env:sync ENV=prod DEBUG=false
everything back (code + infra) to production $ git checkout master $ git merge some-bug # Deploy production # Fast -> same container images $ symfony deploy ENV=prod DEBUG=false
$ symfony php -r 'echo $_SERVER["DATABASE_URL"];' postgres://main:main@127.0.0.1:30002/main?sslmode=disable&charset=utf8&serverVersion=10 # Env vars are useful with bin/console as well $ symfony console ... # Works for "some" other commands as well (connects to the SymfonyCloud DB) $ symfony run psql SymfonyCloud Environment variables are set