Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Symfony @ OpenSky
Pablo Godel
Symfony @ OpenSky
What is OpenSky?
Symfony @ OpenSky
What is OpenSky?
• Multiple businesses powered by Symfony:
1. opensky.com
2. dotandbo.com
3. 55mulberry....
Symfony @ OpenSky
What is OpenSky?
• Multiple businesses powered by Symfony:
1. opensky.com
2. dotandbo.com
3. 55mulberry....
Symfony @ OpenSky
What is OpenSky?
• Multiple businesses powered by Symfony:
1. opensky.com
2. dotandbo.com
3. 55mulberry....
Symfony @ OpenSky
HISTORY
Symfony @ OpenSky
HISTORY
Symfony @ OpenSky
• Early adopter of Symfony2 in 2010 before 2.0
stable was released
History
Symfony @ OpenSky
• Early adopter of Symfony2 in 2010 before 2.0
stable was released
• Migrated from Magento -> symfony1 -...
Symfony @ OpenSky
• Early adopter of Symfony2 in 2010 before 2.0
stable was released
• Migrated from Magento -> symfony1 -...
Symfony @ OpenSky
THE CURRENT STACK
Symfony @ OpenSky
• Symfony 2.8
• RequireJS + Backbone
• PHP 7.1.10
• MySQL 5.6 + MongoDB 3.2
• Redis
• Varnish + Nginx
• ...
Symfony @ OpenSky
• ~400 Controllers
• +800 Routes
• ~1,900 Services
• 285 Commands
• 374 Entities
• 467 Documents
• 808,5...
Symfony @ OpenSky
The Current Stack
Symfony @ OpenSky
The Current Stack
Symfony @ OpenSky
CODING WORKFLOW
Symfony @ OpenSky
Symfony at OpenSky
GitHub Enterprise
GitHub Enterprise
Coding workflow
Symfony @ OpenSky
• production branch (master)
Coding workflow
Symfony @ OpenSky
• production branch (master)
• feature / fix branches
Coding workflow
Symfony @ OpenSky
• production branch (master)
• feature / fix branches
• Pull Requests linked to JIRA
Coding workflow
Symfony @ OpenSky
• production branch (master)
• feature / fix branches
• Pull Requests linked to JIRA
• Integration with J...
Symfony @ OpenSky
• production branch (master)
• feature / fix branches
• Pull Requests linked to JIRA
• Integration with J...
Symfony @ OpenSky
• Symfony Coding Standards
Coding workflow
Symfony @ OpenSky
• Symfony Coding Standards
• Short Array Syntax
Coding workflow
Symfony @ OpenSky
• Symfony Coding Standards
• Short Array Syntax
• Ordered Use Statements
Coding workflow
Symfony @ OpenSky
• Symfony Coding Standards
• Short Array Syntax
• Ordered Use Statements
• Ensuring an EOL at end of file...
Symfony @ OpenSky
• PHP7 Type-Hints when possible
Coding workflow
Symfony @ OpenSky
• PHP7 Type-Hints when possible
• DocBlocks only when adds clarity
Coding workflow
Symfony @ OpenSky
• PHP7 Type-Hints when possible
• DocBlocks only when adds clarity
• ClassName::class
Coding workflow
Symfony @ OpenSky
• PHP7 Type-Hints when possible
• DocBlocks only when adds clarity
• ClassName::class
• ‘NamespaceClassN...
Symfony @ OpenSky
• PHP7 Type-Hints when possible
• DocBlocks only when adds clarity
• ClassName::class
• ‘NamespaceClassN...
Symfony @ OpenSky
• PHP7 Type-Hints when possible
• DocBlocks only when adds clarity
• ClassName::class
• ‘NamespaceClassN...
Symfony @ OpenSky
• PHP7 Type-Hints when possible
• DocBlocks only when adds clarity
• ClassName::class
• ‘NamespaceClassN...
Symfony @ OpenSky
Before production deployment:
Coding workflow
Symfony @ OpenSky
Before production deployment:
• Peer Reviews using GitHub PRs
Coding workflow
Symfony @ OpenSky
Before production deployment:
• Peer Reviews using GitHub PRs
• 100% test pass (unit & functional)
Codin...
Symfony @ OpenSky
Before production deployment:
• Peer Reviews using GitHub PRs
• 100% test pass (unit & functional)
• Int...
Symfony @ OpenSky
Before production deployment:
• Peer Reviews using GitHub PRs
• 100% test pass (unit & functional)
• Int...
Symfony @ OpenSky
SYMFONY BUNDLES
Symfony @ OpenSky
• Split things into broad bundles. Don’t over
bundle.
Symfony Bundles
Symfony @ OpenSky
• Split things into broad bundles. Don’t over
bundle.
• MainBundle
Symfony Bundles
Symfony @ OpenSky
• Split things into broad bundles. Don’t over
bundle.
• MainBundle
• AdminBundle (500+ routes, 300 extra...
Symfony @ OpenSky
• Split things into broad bundles. Don’t over
bundle.
• MainBundle
• AdminBundle (500+ routes, 300 extra...
Symfony @ OpenSky
• Split things into broad bundles. Don’t over
bundle.
• MainBundle
• AdminBundle (500+ routes, 300 extra...
Symfony @ OpenSky
• Split things into broad bundles. Don’t over
bundle.
• MainBundle
• AdminBundle (500+ routes, 300 extra...
Symfony @ OpenSky
• Split things into broad bundles. Don’t over
bundle.
• MainBundle
• AdminBundle (500+ routes, 300 extra...
Symfony @ OpenSky
• Split things into broad bundles. Don’t over
bundle.
• MainBundle
• AdminBundle (500+ routes, 300 extra...
Symfony @ OpenSky
DOCTRINE
Symfony @ OpenSky
• MongoDB and MySQL together
Doctrine
Symfony @ OpenSky
• MongoDB and MySQL together
• References between MongoDB and MySQL
Doctrine
Symfony @ OpenSky
• MongoDB and MySQL together
• References between MongoDB and MySQL
• Using the Doctrine ORM & MongoDB O...
Symfony @ OpenSky
• MongoDB and MySQL together
• References between MongoDB and MySQL
• Using the Doctrine ORM & MongoDB O...
Symfony @ OpenSky
• MongoDB and MySQL together
• References between MongoDB and MySQL
• Using the Doctrine ORM & MongoDB O...
Symfony @ OpenSky
Symfony @ OpenSky
• How long did it take to run?
Doctrine Migrations
Symfony @ OpenSky
• How long did it take to run?
• Is it backwards compatible?
Doctrine Migrations
Symfony @ OpenSky
• How long did it take to run?
• Is it backwards compatible?
• Up & Down
Doctrine Migrations
Symfony @ OpenSky
• How long did it take to run?
• Is it backwards compatible?
• Up & Down
• schema.sql / data.sql up-to-d...
Symfony @ OpenSky
• How long did it take to run?
• Is it backwards compatible?
• Up & Down
• schema.sql / data.sql up-to-d...
Symfony @ OpenSky
• How long did it take to run?
• Is it backwards compatible?
• Up & Down
• schema.sql / data.sql up-to-d...
Symfony @ OpenSky
SYMFONY MISC
Symfony @ OpenSky
• Lean
Controllers
Symfony @ OpenSky
• Lean
• No Business Logic
Controllers
Symfony @ OpenSky
• Lean
• No Business Logic
• Only Flow control
Controllers
Symfony @ OpenSky
• Lean
• No Business Logic
• Only Flow control
• Extend Custom BaseController
Controllers
Symfony @ OpenSky
• Two tiers of authentication implemented using role
voters.
Security
Symfony @ OpenSky
• Two tiers of authentication implemented using role
voters.
• PartiallyAuthenticatedVoter
Security
Symfony @ OpenSky
• Two tiers of authentication implemented using role
voters.
• PartiallyAuthenticatedVoter
• Authenticat...
Symfony @ OpenSky
• Two tiers of authentication implemented using role
voters.
• PartiallyAuthenticatedVoter
• Authenticat...
Symfony @ OpenSky
• Two tiers of authentication implemented using role
voters.
• PartiallyAuthenticatedVoter
• Authenticat...
Symfony @ OpenSky
• Two tiers of authentication implemented using role
voters.
• PartiallyAuthenticatedVoter
• Authenticat...
Symfony @ OpenSky
Runtime Settings/Parameters
• Parameters defined in config/parameters.yml
Symfony @ OpenSky
• Parameters defined in config/parameters.yml
• Override stored in MongoDB
Runtime Settings/Parameters
Symfony @ OpenSky
• Parameters defined in config/parameters.yml
• Override stored in MongoDB
• Parameters can have start & e...
Symfony @ OpenSky
• Parameters defined in config/parameters.yml
• Override stored in MongoDB
• Parameters can have start & e...
Symfony @ OpenSky
• Parameters defined in config/parameters.yml
• Override stored in MongoDB
• Parameters can have start & e...
Symfony @ OpenSky
• Parameters defined in config/parameters.yml
• Override stored in MongoDB
• Parameters can have start & e...
Symfony @ OpenSky
• Parameters defined in config/parameters.yml
• Override stored in MongoDB
• Parameters can have start & e...
Symfony @ OpenSky
Runtime Settings/Parameters
Symfony @ OpenSky
Runtime Settings/Parameters
Symfony @ OpenSky
Runtime Settings/Parameters
Symfony @ OpenSky
EVENTS
Symfony @ OpenSky
• Perform tasks after the response has been sent
to client
Event kernel.terminate
Symfony @ OpenSky
• Perform tasks after the response has been sent
to client
• Store Request Log in MongoDB Collection
Eve...
Symfony @ OpenSky
• Perform tasks after the response has been sent
to client
• Store Request Log in MongoDB Collection
• A...
Symfony @ OpenSky
• Perform tasks after the response has been sent
to client
• Store Request Log in MongoDB Collection
• A...
Symfony @ OpenSky
• Queueing events for async functionality
Events system
Symfony @ OpenSky
• Queueing events for async functionality
• Event serializer/unserializer
Events system
Symfony @ OpenSky
• Queueing events for async functionality
• Event serializer/unserializer
• Scheduling events
Events sys...
Symfony @ OpenSky
• Queueing events for async functionality
• Event serializer/unserializer
• Scheduling events
• Event re...
Symfony @ OpenSky
• Queueing events for async functionality
• Event serializer/unserializer
• Scheduling events
• Event re...
Symfony @ OpenSky
• Queueing events for async functionality
• Event serializer/unserializer
• Scheduling events
• Event re...
Symfony @ OpenSky
Events system
Symfony @ OpenSky
Events system
Symfony @ OpenSky
Events system
Symfony @ OpenSky
Events system
Symfony @ OpenSky
Events system
Symfony @ OpenSky
SLACK
Symfony @ OpenSky
• php-kip using yabot
Slack integration
Symfony @ OpenSky
• php-kip using yabot
• Production deploy queue/line
Slack integration
Symfony @ OpenSky
• php-kip using yabot
• Production deploy queue/line
• Dev environment reservations & deploys
Slack inte...
Symfony @ OpenSky
Symfony at OpenSky
Php-kip using yubot
- Production deploy queue/line
- Dev environment deploys
Slack in...
Symfony @ OpenSky
Symfony at OpenSky
Php-kip using yubot
- Production deploy queue/line
- Dev environment deploys
Slack in...
Symfony @ OpenSky
Symfony at OpenSky
Php-kip using yubot
- Production deploy queue/line
- Dev environment deploys
Slack in...
Symfony @ OpenSky
Slack integration
Symfony @ OpenSky
Slack integration
Symfony @ OpenSky
Slack integration
Symfony @ OpenSky
SEARCH
Symfony @ OpenSky
Search
• Integration with Algolia
Symfony @ OpenSky
• Integration with Algolia
• algolia/algoliasearch-client-php
Search
Symfony @ OpenSky
• Integration with Algolia
• algolia/algoliasearch-client-php
• Update index through async Event
Listene...
Symfony @ OpenSky
Payments
• Integration with Braintree Payments
• braintree/braintree_php
Symfony @ OpenSky
• NPM
• jQuery
• RequireJS
• Backbone
• TwigJS
• Gulp / Less / Sass
The Frontend
Symfony @ OpenSky
• A/B Split Testing using Optimizely for
testing UI/UX changes
• Send small % of traffic to new features
...
Symfony @ OpenSky
TESTING
Symfony @ OpenSky
• pr-nightmare
Testing
Symfony @ OpenSky
• pr-nightmare
• Runs on all commits and pull requests
Testing
Symfony @ OpenSky
• pr-nightmare
• Runs on all commits and pull requests
• Uses PHPChunkit to run 30 minutes of tests in 3...
Symfony @ OpenSky
• pr-nightmare
• Runs on all commits and pull requests
• Uses PHPChunkit to run 30 minutes of tests in 3...
Symfony @ OpenSky
Testing
Symfony @ OpenSky
• ‘@app admin’ annotation to indicate web test
cases which app/kernel to boot up
Testing with PHPUnit
Symfony @ OpenSky
• ‘@app admin’ annotation to indicate web test
cases which app/kernel to boot up
• AutoDataCleanupListen...
Symfony @ OpenSky
• ‘@app admin’ annotation to indicate web test
cases which app/kernel to boot up
• AutoDataCleanupListen...
Symfony @ OpenSky
• ‘@app admin’ annotation to indicate web test
cases which app/kernel to boot up
• AutoDataCleanupListen...
Symfony @ OpenSky
• ‘@app admin’ annotation to indicate web test
cases which app/kernel to boot up
• AutoDataCleanupListen...
Symfony @ OpenSky
Testing with PHPUnit
Symfony @ OpenSky
Testing with PHPUnit
Symfony @ OpenSky
PHPUnit watch
Symfony @ OpenSky
PHPUnit watch
Symfony @ OpenSky
PHPUnit watch
Symfony @ OpenSky
PHPUnit watch
Symfony @ OpenSky
Twig Lint with PHPUnit
Symfony @ OpenSky
Twig Lint with PHPUnit
Symfony @ OpenSky
Twig Lint with PHPUnit
Symfony @ OpenSky
DEPLOYMENT
Symfony @ OpenSky
Deployment
• Use Customized Fabric
• Manually started from Jenkins
• First build task
• Merge feature/fix...
Symfony @ OpenSky
• Final build task
• git checkout
• composer install --no-dev —no-scripts
• Build front controller
• Run...
Symfony @ OpenSky
Questions?
Symfony @ OpenSky
Thank you!
Pablo Godel
@pgodel
http://slideshare.net/pgodel https://joind.in/talk/bfd1e
Upcoming SlideShare
Loading in …5
×

Symfony Live San Francisco 2017 - Symfony @ OpenSky

527 views

Published on

OpenSky is one of the first large ecommerce platforms to use Symfony2. The whole marketplace has been running on Symfony for many years. Over this talk we will share:

how we use the framework and other PHP components
our deployment process
using Doctrine with MySQL and MongoDB
things we learned to avoid
running a large PHPUnit test suite

Published in: Technology
  • Be the first to comment

Symfony Live San Francisco 2017 - Symfony @ OpenSky

  1. 1. Symfony @ OpenSky Pablo Godel
  2. 2. Symfony @ OpenSky What is OpenSky?
  3. 3. Symfony @ OpenSky What is OpenSky? • Multiple businesses powered by Symfony: 1. opensky.com 2. dotandbo.com 3. 55mulberry.com
  4. 4. Symfony @ OpenSky What is OpenSky? • Multiple businesses powered by Symfony: 1. opensky.com 2. dotandbo.com 3. 55mulberry.com • +100 employees
  5. 5. 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
  6. 6. Symfony @ OpenSky HISTORY
  7. 7. Symfony @ OpenSky HISTORY
  8. 8. Symfony @ OpenSky • Early adopter of Symfony2 in 2010 before 2.0 stable was released History
  9. 9. Symfony @ OpenSky • Early adopter of Symfony2 in 2010 before 2.0 stable was released • Migrated from Magento -> symfony1 -> Symfony2 History
  10. 10. 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
  11. 11. Symfony @ OpenSky THE CURRENT STACK
  12. 12. 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
  13. 13. 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
  14. 14. Symfony @ OpenSky The Current Stack
  15. 15. Symfony @ OpenSky The Current Stack
  16. 16. Symfony @ OpenSky CODING WORKFLOW
  17. 17. Symfony @ OpenSky Symfony at OpenSky GitHub Enterprise GitHub Enterprise Coding workflow
  18. 18. Symfony @ OpenSky • production branch (master) Coding workflow
  19. 19. Symfony @ OpenSky • production branch (master) • feature / fix branches Coding workflow
  20. 20. Symfony @ OpenSky • production branch (master) • feature / fix branches • Pull Requests linked to JIRA Coding workflow
  21. 21. Symfony @ OpenSky • production branch (master) • feature / fix branches • Pull Requests linked to JIRA • Integration with Jenkins for Unit/ Functional Tests Coding workflow
  22. 22. 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
  23. 23. Symfony @ OpenSky • Symfony Coding Standards Coding workflow
  24. 24. Symfony @ OpenSky • Symfony Coding Standards • Short Array Syntax Coding workflow
  25. 25. Symfony @ OpenSky • Symfony Coding Standards • Short Array Syntax • Ordered Use Statements Coding workflow
  26. 26. Symfony @ OpenSky • Symfony Coding Standards • Short Array Syntax • Ordered Use Statements • Ensuring an EOL at end of file Coding workflow
  27. 27. Symfony @ OpenSky • PHP7 Type-Hints when possible Coding workflow
  28. 28. Symfony @ OpenSky • PHP7 Type-Hints when possible • DocBlocks only when adds clarity Coding workflow
  29. 29. Symfony @ OpenSky • PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class Coding workflow
  30. 30. Symfony @ OpenSky • PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class • ‘NamespaceClassName’ Coding workflow
  31. 31. Symfony @ OpenSky • PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class • ‘NamespaceClassName’ • In forms use class constant Coding workflow
  32. 32. Symfony @ OpenSky • PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class • ‘NamespaceClassName’ • In forms use class constant • $builder->add('name', TextType::class); Coding workflow
  33. 33. Symfony @ OpenSky • PHP7 Type-Hints when possible • DocBlocks only when adds clarity • ClassName::class • ‘NamespaceClassName’ • In forms use class constant • $builder->add('name', TextType::class); • Always use ‘use’ statement • $time = new DateTime() Coding workflow
  34. 34. Symfony @ OpenSky Before production deployment: Coding workflow
  35. 35. Symfony @ OpenSky Before production deployment: • Peer Reviews using GitHub PRs Coding workflow
  36. 36. Symfony @ OpenSky Before production deployment: • Peer Reviews using GitHub PRs • 100% test pass (unit & functional) Coding workflow
  37. 37. Symfony @ OpenSky Before production deployment: • Peer Reviews using GitHub PRs • 100% test pass (unit & functional) • Integration deploy/testing Coding workflow
  38. 38. 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
  39. 39. Symfony @ OpenSky SYMFONY BUNDLES
  40. 40. Symfony @ OpenSky • Split things into broad bundles. Don’t over bundle. Symfony Bundles
  41. 41. Symfony @ OpenSky • Split things into broad bundles. Don’t over bundle. • MainBundle Symfony Bundles
  42. 42. Symfony @ OpenSky • Split things into broad bundles. Don’t over bundle. • MainBundle • AdminBundle (500+ routes, 300 extra services in the container) Symfony Bundles
  43. 43. Symfony @ OpenSky • Split things into broad bundles. Don’t over bundle. • MainBundle • AdminBundle (500+ routes, 300 extra services in the container) • APIBundle Symfony Bundles
  44. 44. 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
  45. 45. 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
  46. 46. 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
  47. 47. 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
  48. 48. Symfony @ OpenSky DOCTRINE
  49. 49. Symfony @ OpenSky • MongoDB and MySQL together Doctrine
  50. 50. Symfony @ OpenSky • MongoDB and MySQL together • References between MongoDB and MySQL Doctrine
  51. 51. 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
  52. 52. 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
  53. 53. 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
  54. 54. Symfony @ OpenSky
  55. 55. Symfony @ OpenSky • How long did it take to run? Doctrine Migrations
  56. 56. Symfony @ OpenSky • How long did it take to run? • Is it backwards compatible? Doctrine Migrations
  57. 57. Symfony @ OpenSky • How long did it take to run? • Is it backwards compatible? • Up & Down Doctrine Migrations
  58. 58. Symfony @ OpenSky • How long did it take to run? • Is it backwards compatible? • Up & Down • schema.sql / data.sql up-to-date Doctrine Migrations
  59. 59. 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
  60. 60. 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
  61. 61. Symfony @ OpenSky SYMFONY MISC
  62. 62. Symfony @ OpenSky • Lean Controllers
  63. 63. Symfony @ OpenSky • Lean • No Business Logic Controllers
  64. 64. Symfony @ OpenSky • Lean • No Business Logic • Only Flow control Controllers
  65. 65. Symfony @ OpenSky • Lean • No Business Logic • Only Flow control • Extend Custom BaseController Controllers
  66. 66. Symfony @ OpenSky • Two tiers of authentication implemented using role voters. Security
  67. 67. Symfony @ OpenSky • Two tiers of authentication implemented using role voters. • PartiallyAuthenticatedVoter Security
  68. 68. Symfony @ OpenSky • Two tiers of authentication implemented using role voters. • PartiallyAuthenticatedVoter • AuthenticatedRecentlyVoter Security
  69. 69. 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
  70. 70. 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
  71. 71. 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
  72. 72. Symfony @ OpenSky Runtime Settings/Parameters • Parameters defined in config/parameters.yml
  73. 73. Symfony @ OpenSky • Parameters defined in config/parameters.yml • Override stored in MongoDB Runtime Settings/Parameters
  74. 74. Symfony @ OpenSky • Parameters defined in config/parameters.yml • Override stored in MongoDB • Parameters can have start & end datetime Runtime Settings/Parameters
  75. 75. 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
  76. 76. 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
  77. 77. 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
  78. 78. 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
  79. 79. Symfony @ OpenSky Runtime Settings/Parameters
  80. 80. Symfony @ OpenSky Runtime Settings/Parameters
  81. 81. Symfony @ OpenSky Runtime Settings/Parameters
  82. 82. Symfony @ OpenSky EVENTS
  83. 83. Symfony @ OpenSky • Perform tasks after the response has been sent to client Event kernel.terminate
  84. 84. Symfony @ OpenSky • Perform tasks after the response has been sent to client • Store Request Log in MongoDB Collection Event kernel.terminate
  85. 85. 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
  86. 86. 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
  87. 87. Symfony @ OpenSky • Queueing events for async functionality Events system
  88. 88. Symfony @ OpenSky • Queueing events for async functionality • Event serializer/unserializer Events system
  89. 89. Symfony @ OpenSky • Queueing events for async functionality • Event serializer/unserializer • Scheduling events Events system
  90. 90. Symfony @ OpenSky • Queueing events for async functionality • Event serializer/unserializer • Scheduling events • Event retries, retry max amount Events system
  91. 91. Symfony @ OpenSky • Queueing events for async functionality • Event serializer/unserializer • Scheduling events • Event retries, retry max amount • One queue per mongodb collection Events system
  92. 92. 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
  93. 93. Symfony @ OpenSky Events system
  94. 94. Symfony @ OpenSky Events system
  95. 95. Symfony @ OpenSky Events system
  96. 96. Symfony @ OpenSky Events system
  97. 97. Symfony @ OpenSky Events system
  98. 98. Symfony @ OpenSky SLACK
  99. 99. Symfony @ OpenSky • php-kip using yabot Slack integration
  100. 100. Symfony @ OpenSky • php-kip using yabot • Production deploy queue/line Slack integration
  101. 101. Symfony @ OpenSky • php-kip using yabot • Production deploy queue/line • Dev environment reservations & deploys Slack integration
  102. 102. Symfony @ OpenSky Symfony at OpenSky Php-kip using yubot - Production deploy queue/line - Dev environment deploys Slack integration
  103. 103. Symfony @ OpenSky Symfony at OpenSky Php-kip using yubot - Production deploy queue/line - Dev environment deploys Slack integration
  104. 104. Symfony @ OpenSky Symfony at OpenSky Php-kip using yubot - Production deploy queue/line - Dev environment deploys Slack integration
  105. 105. Symfony @ OpenSky Slack integration
  106. 106. Symfony @ OpenSky Slack integration
  107. 107. Symfony @ OpenSky Slack integration
  108. 108. Symfony @ OpenSky SEARCH
  109. 109. Symfony @ OpenSky Search • Integration with Algolia
  110. 110. Symfony @ OpenSky • Integration with Algolia • algolia/algoliasearch-client-php Search
  111. 111. Symfony @ OpenSky • Integration with Algolia • algolia/algoliasearch-client-php • Update index through async Event Listeners Search
  112. 112. Symfony @ OpenSky Payments • Integration with Braintree Payments • braintree/braintree_php
  113. 113. Symfony @ OpenSky • NPM • jQuery • RequireJS • Backbone • TwigJS • Gulp / Less / Sass The Frontend
  114. 114. 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
  115. 115. Symfony @ OpenSky TESTING
  116. 116. Symfony @ OpenSky • pr-nightmare Testing
  117. 117. Symfony @ OpenSky • pr-nightmare • Runs on all commits and pull requests Testing
  118. 118. 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
  119. 119. 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
  120. 120. Symfony @ OpenSky Testing
  121. 121. Symfony @ OpenSky • ‘@app admin’ annotation to indicate web test cases which app/kernel to boot up Testing with PHPUnit
  122. 122. 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
  123. 123. 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
  124. 124. 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
  125. 125. 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
  126. 126. Symfony @ OpenSky Testing with PHPUnit
  127. 127. Symfony @ OpenSky Testing with PHPUnit
  128. 128. Symfony @ OpenSky PHPUnit watch
  129. 129. Symfony @ OpenSky PHPUnit watch
  130. 130. Symfony @ OpenSky PHPUnit watch
  131. 131. Symfony @ OpenSky PHPUnit watch
  132. 132. Symfony @ OpenSky Twig Lint with PHPUnit
  133. 133. Symfony @ OpenSky Twig Lint with PHPUnit
  134. 134. Symfony @ OpenSky Twig Lint with PHPUnit
  135. 135. Symfony @ OpenSky DEPLOYMENT
  136. 136. Symfony @ OpenSky Deployment • Use Customized Fabric • Manually started from Jenkins • First build task • Merge feature/fix branch into master • Create Tag
  137. 137. 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
  138. 138. Symfony @ OpenSky Questions?
  139. 139. Symfony @ OpenSky Thank you! Pablo Godel @pgodel http://slideshare.net/pgodel https://joind.in/talk/bfd1e

×