Successfully reported this slideshow.
Your SlideShare is downloading. ×

Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and Panther

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Progressively enhance
your Symfony 4 app
symfonycon.les-tilleuls.coop @dunglas
Kévin Dunglas
❏ Les-Tilleuls.coop’s Founder
❏ Symfony Core Team

Panther, Serializer...
symfonycon.les-tilleuls.coop @dunglas
✍ Self-managed since 2011
35 people, 1,000% in 6 years
👷 ➡ jobs@les-tilleuls.coop

YouTube videos are no longer supported on SlideShare

View original on YouTube

YouTube videos are no longer supported on SlideShare

View original on YouTube

YouTube videos are no longer supported on SlideShare

View original on YouTube

YouTube videos are no longer supported on SlideShare

View original on YouTube

Loading in …3
×

Check these out next

1 of 59 Ad

Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and Panther

Download to read offline

Thanks to the new capabilities of the web platform (web components, Progressive Web Apps…) and the rise of modern JS libraries (Vue, React, Angular) almost all modern Symfony applications must leverage the frontend ecosystem.
Symfony 4 embed many gems that make it easy to integrate modern JavaScript within the framework, including the first component entirely written in JS: Webpack Encore.

In Symfony 4.2, another component that is super convenient for apps containing JS code has been released: Panther, a PHP library compatible with BrowserKit, that drives real web browsers to create end-to-end (E2E) tests with ease.
During this talk, I'll show you how to cleanly integrate modern JavaScript code with Symfony and Twig and how to test such applications using Panther.

The examples will use VueJS, because it’s probably the easiest JS framework to get started with as a PHP developer, but all the tips and tricks will be applicable with other libraries such as React or Angular.

Finally, we'll add some real time capabilities to our app using Mercure.rocks

Thanks to the new capabilities of the web platform (web components, Progressive Web Apps…) and the rise of modern JS libraries (Vue, React, Angular) almost all modern Symfony applications must leverage the frontend ecosystem.
Symfony 4 embed many gems that make it easy to integrate modern JavaScript within the framework, including the first component entirely written in JS: Webpack Encore.

In Symfony 4.2, another component that is super convenient for apps containing JS code has been released: Panther, a PHP library compatible with BrowserKit, that drives real web browsers to create end-to-end (E2E) tests with ease.
During this talk, I'll show you how to cleanly integrate modern JavaScript code with Symfony and Twig and how to test such applications using Panther.

The examples will use VueJS, because it’s probably the easiest JS framework to get started with as a PHP developer, but all the tips and tricks will be applicable with other libraries such as React or Angular.

Finally, we'll add some real time capabilities to our app using Mercure.rocks

Advertisement
Advertisement

More Related Content

Slideshows for you (20)

Similar to Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and Panther (20)

Advertisement

Recently uploaded (20)

Advertisement

Progressively enhance your Symfony 4 app using Vue, API Platform, Mercure and Panther

  1. 1. Progressively enhance your Symfony 4 app
  2. 2. symfonycon.les-tilleuls.coop @dunglas Kévin Dunglas ❏ Les-Tilleuls.coop’s Founder ❏ Symfony Core Team
 Panther, Serializer, WebLink, PropertyInfo, autowiring… ❏ API Platform and Mercure creator @dunglas
  3. 3. symfonycon.les-tilleuls.coop @dunglas ✍ Self-managed since 2011 35 people, 1,000% in 6 years 👷 ➡ jobs@les-tilleuls.coop
  4. 4. symfonycon.les-tilleuls.coop @dunglas
  5. 5. symfonycon.les-tilleuls.coop @dunglas Agenda A joind.in clone in 40 minutes? 1. A modern Symfony app (MakerBundle, Doctrine) 2. Integrating Vue.js (Encore, API Platform) 3. UI Testing (Panther) 4. Real time update (Mercure)
  6. 6. symfonycon.les-tilleuls.coop Our final app: try it now!
  7. 7. symfonycon.les-tilleuls.coop @dunglas MakerBundle FTW! A modern Symfony app
  8. 8. symfonycon.les-tilleuls.coop @dunglas Install the Website Skeleton Symfony full stack (SF + Twig + Doctrine)
  9. 9. symfonycon.les-tilleuls.coop @dunglas MakerBundle ❏ Code scaffolding ❏ Entities ❏ Controllers ❏ Forms and CRUD ❏ Users and security (auth, voter) ❏ Tests ❏ Commands
  10. 10. symfonycon.les-tilleuls.coop @dunglas Updating the DB, creating a controller
  11. 11. symfonycon.les-tilleuls.coop @dunglas The controller
  12. 12. symfonycon.les-tilleuls.coop @dunglas Twig template: a partial
  13. 13. Twig templates
  14. 14. symfonycon.les-tilleuls.coop @dunglas Our basic website is ready, thanks MakerBundle!
  15. 15. symfonycon.les-tilleuls.coop @dunglas A better UX thanks to Encore and API Platform Integrating Vue.js
  16. 16. symfonycon.les-tilleuls.coop @dunglas A modern feedback system ❏ Rate a talk, using a star based selector ❏ Post a comment ❏ No page reload, rich form, no form component ❏ Server-side: hypermedia API ❏ Client-side: web component (in JS)
  17. 17. symfonycon.les-tilleuls.coop @dunglas Install API Platform
  18. 18. symfonycon.les-tilleuls.coop @dunglas Tweaking the API
  19. 19. symfonycon.les-tilleuls.coop @dunglas Vue.js ❏ Progressive framework for building interfaces ❏ Designed to be incrementally adoptable ❏ Focused on the view layer ❏ Can also power Single-Page Applications
  20. 20. symfonycon.les-tilleuls.coop @dunglas Install Symfony Encore
  21. 21. symfonycon.les-tilleuls.coop @dunglasJoke stolen from @iamdevloper You just installed 600+ packages,
 welcome to the JS world 😉
  22. 22. symfonycon.les-tilleuls.coop @dunglas Enable Vue, register our component
  23. 23. symfonycon.les-tilleuls.coop @dunglas
  24. 24. symfonycon.les-tilleuls.coop @dunglas A Vue component
  25. 25. notation : notation @ v-model The View
  26. 26. The ViewModel
  27. 27. symfonycon.les-tilleuls.coop @dunglas Loading the Vue component in Twig
  28. 28. symfonycon.les-tilleuls.coop @dunglas Panther: the new feline on the block 😺end-2-end testing
  29. 29. symfonycon.les-tilleuls.coop @dunglas
  30. 30. symfonycon.les-tilleuls.coop @dunglas Symfony Panther: an E2E testing tool ❏ Executes real web browsers (Chrome by default) ❏ Supports JavaScript, CSS, DOM… ❏ Uses the W3C WebDriver Protocol ❏ Implements the APIs of ❏ Symfony BrowserKit (you already know it!) ❏ Facebook’s PHP WebDriver ❏ Provide some extra methods: ❏ wait, execute JS, screenshot, click… ❏ Standalone lib, for testing and web scraping
  31. 31. symfonycon.les-tilleuls.coop @dunglas Symfony Panther: developer-friendly ❏ Nothing to install (except Panther) ❏ Nothing to configure ❏ neither Selenium, ❏ nor a web server ❏ Panther just works!
  32. 32. symfonycon.les-tilleuls.coop @dunglas Populating the database with Alice Fixtures
  33. 33. symfonycon.les-tilleuls.coop @dunglas The Panther test
  34. 34. symfonycon.les-tilleuls.coop @dunglas The JavaScript is executed!
  35. 35. symfonycon.les-tilleuls.coop @dunglas As well as HTTP requests, you can even take screenshots!
  36. 36. symfonycon.les-tilleuls.coop @dunglas The screenshot 📸, by Panther
  37. 37. symfonycon.les-tilleuls.coop @dunglas Introducing the Mercure protocol Real Time
  38. 38. symfonycon.les-tilleuls.coop
  39. 39. symfonycon.les-tilleuls.coop @dunglas
  40. 40. symfonycon.les-tilleuls.coop @dunglas
  41. 41. symfonycon.les-tilleuls.coop @dunglas Installing MercureBundle
  42. 42. symfonycon.les-tilleuls.coop @dunglas The API
  43. 43. symfonycon.les-tilleuls.coop @dunglas
  44. 44. symfonycon.les-tilleuls.coop @dunglas
  45. 45. The ViewModel
  46. 46. Subscribing to real time events
  47. 47. symfonycon.les-tilleuls.coop @dunglas The missing parts ❏ Validation ❏ automated in 4.3? symfony/symfony#27735 ❏ User and authentication ❏ make:user, make:auth (no FOSUserBundle please!) ❏ API Platform access control ❏ Deployment ❏ SymfonyCloud: symfony deploy 😻 ❏ Managed Mercure.rocks (alpha)
  48. 48. symfonycon.les-tilleuls.coop @dunglas One step further ❏ Admin SPA, for free ❏ api-platform.com/docs/admin ❏ Vue or React SPA, or native app, for free ❏ api-platform.com/docs/client-generator/vuejs/ We can help you!
  49. 49. symfonycon.les-tilleuls.coop @dunglas Thanks! Any question?

×