symfony live san francisco 2017 - symfony @ opensky

139
Symfony @ OpenSky Pablo Godel

Upload: pablo-godel

Post on 21-Jan-2018

387 views

Category:

Technology


9 download

TRANSCRIPT

Page 1: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSkyPablo Godel

Page 2: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

What is OpenSky?

Page 3: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

What is OpenSky?• Multiple businesses powered by Symfony:

1. opensky.com 2. dotandbo.com 3. 55mulberry.com

Page 4: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

What is OpenSky?• Multiple businesses powered by Symfony:

1. opensky.com 2. dotandbo.com 3. 55mulberry.com

• +100 employees

Page 5: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

What is OpenSky?• Multiple businesses powered by Symfony:

1. opensky.com 2. dotandbo.com 3. 55mulberry.com

• +100 employees • Offices all around the world in New York,

Portland, Nashville, Miami, Chico, Bucharest and Los Angeles

Page 6: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

HISTORY

Page 7: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

HISTORY

Page 8: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Early adopter of Symfony2 in 2010 before 2.0 stable was released

History

Page 9: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Early adopter of Symfony2 in 2010 before 2.0 stable was released

• Migrated from Magento -> symfony1 -> Symfony2

History

Page 10: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Early adopter of Symfony2 in 2010 before 2.0 stable was released

• Migrated from Magento -> symfony1 -> Symfony2

• Aspects of Magento cart utilized throughout migration process until completely phased out with proprietary cart/checkout technology

History

Page 11: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

THE CURRENT STACK

Page 12: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Symfony 2.8 • RequireJS + Backbone • PHP 7.1.10 • MySQL 5.6 + MongoDB 3.2 • Redis • Varnish + Nginx • VMWare • Vagrant + VirtualBox for Dev VMs

The Current Stack

Page 13: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• ~400 Controllers • +800 Routes • ~1,900 Services • 285 Commands • 374 Entities • 467 Documents • 808,532 LoC • 3,738 Classes • 156 Interfaces • 46 Traits • +10,000 Unit Tests

The Current Stack

Page 14: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

The Current Stack

Page 15: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

The Current Stack

Page 16: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

CODING WORKFLOW

Page 17: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Symfony at OpenSkyGitHub Enterprise

GitHub Enterprise

Coding workflow

Page 18: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• production branch (master)

Coding workflow

Page 19: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• production branch (master) • feature / fix branches

Coding workflow

Page 20: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• production branch (master) • feature / fix branches • Pull Requests linked to JIRA

Coding workflow

Page 21: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• production branch (master) • feature / fix branches • Pull Requests linked to JIRA • Integration with Jenkins for Unit/

Functional Tests

Coding workflow

Page 22: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• production branch (master) • feature / fix branches • Pull Requests linked to JIRA • Integration with Jenkins for Unit/

Functional Tests • Pre-commit Hooks for php-cs-fixer,

gulp-jshint, gulp-sass-lint

Coding workflow

Page 23: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Symfony Coding Standards

Coding workflow

Page 24: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Symfony Coding Standards • Short Array Syntax

Coding workflow

Page 25: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Symfony Coding Standards • Short Array Syntax • Ordered Use Statements

Coding workflow

Page 26: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Symfony Coding Standards • Short Array Syntax • Ordered Use Statements • Ensuring an EOL at end of file

Coding workflow

Page 27: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• PHP7 Type-Hints when possible

Coding workflow

Page 28: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• PHP7 Type-Hints when possible • DocBlocks only when adds clarity

Coding workflow

Page 29: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class

Coding workflow

Page 30: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class

• ‘\Namespace\ClassName’

Coding workflow

Page 31: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class

• ‘\Namespace\ClassName’ • In forms use class constant

Coding workflow

Page 32: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class

• ‘\Namespace\ClassName’ • In forms use class constant

• $builder->add('name', TextType::class);

Coding workflow

Page 33: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class

• ‘\Namespace\ClassName’ • In forms use class constant

• $builder->add('name', TextType::class); • Always use ‘use’ statement

• $time = new \DateTime()

Coding workflow

Page 34: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Before production deployment:

Coding workflow

Page 35: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Before production deployment: • Peer Reviews using GitHub PRs

Coding workflow

Page 36: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Before production deployment: • Peer Reviews using GitHub PRs • 100% test pass (unit & functional)

Coding workflow

Page 37: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Before production deployment: • Peer Reviews using GitHub PRs • 100% test pass (unit & functional) • Integration deploy/testing

Coding workflow

Page 38: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Before production deployment: • Peer Reviews using GitHub PRs • 100% test pass (unit & functional) • Integration deploy/testing • UA / QA pass (tracked in JIRA)

Coding workflow

Page 39: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

SYMFONY BUNDLES

Page 40: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Split things into broad bundles. Don’t over bundle.

Symfony Bundles

Page 41: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Split things into broad bundles. Don’t over bundle. • MainBundle

Symfony Bundles

Page 42: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Split things into broad bundles. Don’t over bundle. • MainBundle • AdminBundle (500+ routes, 300 extra

services in the container)

Symfony Bundles

Page 43: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Split things into broad bundles. Don’t over bundle. • MainBundle • AdminBundle (500+ routes, 300 extra

services in the container) • APIBundle

Symfony Bundles

Page 44: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Split things into broad bundles. Don’t over bundle. • MainBundle • AdminBundle (500+ routes, 300 extra

services in the container) • APIBundle

• 3rd Party Bundles

Symfony Bundles

Page 45: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Split things into broad bundles. Don’t over bundle. • MainBundle • AdminBundle (500+ routes, 300 extra

services in the container) • APIBundle

• 3rd Party Bundles • AvalancheImagineBundle

Symfony Bundles

Page 46: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Split things into broad bundles. Don’t over bundle. • MainBundle • AdminBundle (500+ routes, 300 extra

services in the container) • APIBundle

• 3rd Party Bundles • AvalancheImagineBundle • FOSUserBundle

Symfony Bundles

Page 47: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Split things into broad bundles. Don’t over bundle. • MainBundle • AdminBundle (500+ routes, 300 extra

services in the container) • APIBundle

• 3rd Party Bundles • AvalancheImagineBundle • FOSUserBundle • Using 3rd party bundles may impact

maintainability in the long term

Symfony Bundles

Page 48: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

DOCTRINE

Page 49: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• MongoDB and MySQL together

Doctrine

Page 50: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• MongoDB and MySQL together • References between MongoDB and MySQL

Doctrine

Page 51: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• MongoDB and MySQL together • References between MongoDB and MySQL • Using the Doctrine ORM & MongoDB ODM to

make the models for the two databases transparent to the application.

Doctrine

Page 52: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• MongoDB and MySQL together • References between MongoDB and MySQL • Using the Doctrine ORM & MongoDB ODM to

make the models for the two databases transparent to the application.

• Never delete data due to referential integrity problems. Use soft delete (deletedAt)

Doctrine

Page 53: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• MongoDB and MySQL together • References between MongoDB and MySQL • Using the Doctrine ORM & MongoDB ODM to

make the models for the two databases transparent to the application.

• Never delete data due to referential integrity problems. Use soft delete (deletedAt)

• Traits for common functionality like createdAt/updatedAt/deletedAt

Doctrine

Page 54: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Page 55: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• How long did it take to run?

Doctrine Migrations

Page 56: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• How long did it take to run? • Is it backwards compatible?

Doctrine Migrations

Page 57: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• How long did it take to run? • Is it backwards compatible? • Up & Down

Doctrine Migrations

Page 58: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• How long did it take to run? • Is it backwards compatible? • Up & Down • schema.sql / data.sql up-to-date

Doctrine Migrations

Page 59: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• How long did it take to run? • Is it backwards compatible? • Up & Down • schema.sql / data.sql up-to-date • Add indexes

Doctrine Migrations

Page 60: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• How long did it take to run? • Is it backwards compatible? • Up & Down • schema.sql / data.sql up-to-date • Add indexes • Remove data later in separate

migration

Doctrine Migrations

Page 61: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

SYMFONY MISC

Page 62: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Lean

Controllers

Page 63: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Lean • No Business Logic

Controllers

Page 64: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Lean • No Business Logic • Only Flow control

Controllers

Page 65: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Lean • No Business Logic • Only Flow control • Extend Custom BaseController

Controllers

Page 66: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Two tiers of authentication implemented using role voters.

Security

Page 67: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Two tiers of authentication implemented using role voters. • PartiallyAuthenticatedVoter

Security

Page 68: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Two tiers of authentication implemented using role voters. • PartiallyAuthenticatedVoter • AuthenticatedRecentlyVoter

Security

Page 69: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Two tiers of authentication implemented using role voters. • PartiallyAuthenticatedVoter • AuthenticatedRecentlyVoter

• When a user is recently authenticated, they are logged in to 2nd tier of authentication and have access to account, checkout, etc. After 15 minutes of inactivity, user is logged out of 2nd tier.

Security

Page 70: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Two tiers of authentication implemented using role voters. • PartiallyAuthenticatedVoter • AuthenticatedRecentlyVoter

• When a user is recently authenticated, they are logged in to 2nd tier of authentication and have access to account, checkout, etc. After 15 minutes of inactivity, user is logged out of 2nd tier.

• Admin integrates with LDAP (using zendframework/zend-ldap)

Security

Page 71: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Two tiers of authentication implemented using role voters. • PartiallyAuthenticatedVoter • AuthenticatedRecentlyVoter

• When a user is recently authenticated, they are logged in to 2nd tier of authentication and have access to account, checkout, etc. After 15 minutes of inactivity, user is logged out of 2nd tier.

• Admin integrates with LDAP (using zendframework/zend-ldap)

• Multiple firewalls/authentication providers for consumer facing, admin and api.

Security

Page 72: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Runtime Settings/Parameters• Parameters defined in config/parameters.yml

Page 73: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Parameters defined in config/parameters.yml • Override stored in MongoDB

Runtime Settings/Parameters

Page 74: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Parameters defined in config/parameters.yml • Override stored in MongoDB • Parameters can have start & end datetime

Runtime Settings/Parameters

Page 75: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Parameters defined in config/parameters.yml • Override stored in MongoDB • Parameters can have start & end datetime • All parameters stored in cache

Runtime Settings/Parameters

Page 76: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Parameters defined in config/parameters.yml • Override stored in MongoDB • Parameters can have start & end datetime • All parameters stored in cache • When parameter value is changed, cache is

updated and queue workers restarted

Runtime Settings/Parameters

Page 77: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Parameters defined in config/parameters.yml • Override stored in MongoDB • Parameters can have start & end datetime • All parameters stored in cache • When parameter value is changed, cache is

updated and queue workers restarted • Allows for configuration changes without

deployment

Runtime Settings/Parameters

Page 78: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Parameters defined in config/parameters.yml • Override stored in MongoDB • Parameters can have start & end datetime • All parameters stored in cache • When parameter value is changed, cache is

updated and queue workers restarted • Allows for configuration changes without

deployment • Heavily used for feature flags and enable/

disable of new features

Runtime Settings/Parameters

Page 79: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Runtime Settings/Parameters

Page 80: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Runtime Settings/Parameters

Page 81: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Runtime Settings/Parameters

Page 82: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

EVENTS

Page 83: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Perform tasks after the response has been sent to client

Event kernel.terminate

Page 84: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Perform tasks after the response has been sent to client • Store Request Log in MongoDB Collection

Event kernel.terminate

Page 85: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Perform tasks after the response has been sent to client • Store Request Log in MongoDB Collection • Analyze request for further actions

Event kernel.terminate

Page 86: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Perform tasks after the response has been sent to client • Store Request Log in MongoDB Collection • Analyze request for further actions

• Only effective with FastCGI

Event kernel.terminate

Page 87: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Queueing events for async functionality

Events system

Page 88: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Queueing events for async functionality • Event serializer/unserializer

Events system

Page 89: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Queueing events for async functionality • Event serializer/unserializer • Scheduling events

Events system

Page 90: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Queueing events for async functionality • Event serializer/unserializer • Scheduling events • Event retries, retry max amount

Events system

Page 91: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Queueing events for async functionality • Event serializer/unserializer • Scheduling events • Event retries, retry max amount • One queue per mongodb collection

Events system

Page 92: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Queueing events for async functionality • Event serializer/unserializer • Scheduling events • Event retries, retry max amount • One queue per mongodb collection • Queue workers managed with Supervisord

Events system

Page 93: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Events system

Page 94: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Events system

Page 95: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Events system

Page 96: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Events system

Page 97: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Events system

Page 98: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

SLACK

Page 99: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• php-kip using yabot

Slack integration

Page 100: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• php-kip using yabot • Production deploy queue/line

Slack integration

Page 101: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• php-kip using yabot • Production deploy queue/line • Dev environment reservations & deploys

Slack integration

Page 102: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Symfony at OpenSkyPhp-kip using yubot

- Production deploy queue/line - Dev environment deploys

Slack integration

Page 103: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Symfony at OpenSkyPhp-kip using yubot

- Production deploy queue/line - Dev environment deploys

Slack integration

Page 104: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Symfony at OpenSkyPhp-kip using yubot

- Production deploy queue/line - Dev environment deploys

Slack integration

Page 105: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Slack integration

Page 106: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Slack integration

Page 107: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Slack integration

Page 108: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

SEARCH

Page 109: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Search

• Integration with Algolia

Page 110: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Integration with Algolia • algolia/algoliasearch-client-php

Search

Page 111: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Integration with Algolia • algolia/algoliasearch-client-php • Update index through async Event

Listeners

Search

Page 112: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Payments• Integration with Braintree Payments • braintree/braintree_php

Page 113: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• NPM • jQuery • RequireJS • Backbone • TwigJS • Gulp / Less / Sass

The Frontend

Page 114: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• A/B Split Testing using Optimizely for testing UI/UX changes

• Send small % of traffic to new features • GoogleAnalytics tracking conversion rate

The Frontend

Page 115: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

TESTING

Page 116: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• pr-nightmareTesting

Page 117: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• pr-nightmare • Runs on all commits and pull requests

Testing

Page 118: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• pr-nightmare • Runs on all commits and pull requests • Uses PHPChunkit to run 30 minutes of tests in 3

minutes by running groups of tests in parallel across multiple servers. https://github.com/jwage/phpchunkit

Testing

Page 119: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• pr-nightmare • Runs on all commits and pull requests • Uses PHPChunkit to run 30 minutes of tests in 3

minutes by running groups of tests in parallel across multiple servers. https://github.com/jwage/phpchunkit

• Selenium for browser functional testing

Testing

Page 120: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Testing

Page 121: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• ‘@app admin’ annotation to indicate web test cases which app/kernel to boot up

Testing with PHPUnit

Page 122: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• ‘@app admin’ annotation to indicate web test cases which app/kernel to boot up

• AutoDataCleanupListener keeps tracks of what collections and tables were inserted to in a test and cleans up afterwards. This used to be explicitly required by the developer but happens automatically now

Testing with PHPUnit

Page 123: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• ‘@app admin’ annotation to indicate web test cases which app/kernel to boot up

• AutoDataCleanupListener keeps tracks of what collections and tables were inserted to in a test and cleans up afterwards. This used to be explicitly required by the developer but happens automatically now

• AbstractTwigLintTest: Twig linting. Loads up all twig files to make sure there are no parse errors

Testing with PHPUnit

Page 124: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• ‘@app admin’ annotation to indicate web test cases which app/kernel to boot up

• AutoDataCleanupListener keeps tracks of what collections and tables were inserted to in a test and cleans up afterwards. This used to be explicitly required by the developer but happens automatically now

• AbstractTwigLintTest: Twig linting. Loads up all twig files to make sure there are no parse errors

• Generating unit tests from class definitions

Testing with PHPUnit

Page 125: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• ‘@app admin’ annotation to indicate web test cases which app/kernel to boot up

• AutoDataCleanupListener keeps tracks of what collections and tables were inserted to in a test and cleans up afterwards. This used to be explicitly required by the developer but happens automatically now

• AbstractTwigLintTest: Twig linting. Loads up all twig files to make sure there are no parse errors

• Generating unit tests from class definitions • PHPUnit watch command

Testing with PHPUnit

Page 126: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Testing with PHPUnit

Page 127: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Testing with PHPUnit

Page 128: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

PHPUnit watch

Page 129: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

PHPUnit watch

Page 130: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

PHPUnit watch

Page 131: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

PHPUnit watch

Page 132: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Twig Lint with PHPUnit

Page 133: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Twig Lint with PHPUnit

Page 134: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Twig Lint with PHPUnit

Page 135: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

DEPLOYMENT

Page 136: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Deployment• Use Customized Fabric • Manually started from Jenkins • First build task

• Merge feature/fix branch into master

• Create Tag

Page 137: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

• Final build task • git checkout • composer install --no-dev —no-scripts • Build front controller • Run gulp, requires, less, sass • Warmup cache for each app • Assetic dump • Build artifacts file & distribute it to

servers • Run MySQL & MongoDB Migrations • Rotate logs • Restart php-fpm • Reload Varnish and nginx • Restart queue workers

Deployment• Use Customized Fabric • Manually started from Jenkins • First build task

• Merge feature/fix branch into master

• Create Tag

Page 138: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Questions?

Page 139: Symfony Live San Francisco 2017 - Symfony @ OpenSky

Symfony @ OpenSky

Thank you!Pablo Godel

@pgodel

http://slideshare.net/pgodel https://joind.in/talk/bfd1e