Creating a Reusable (& Amazing) Symfony Bundle

2:21:06
Buy Access

Want to share some code between projects, or maybe with the whole world? Let's do it! By creating a Symfony bundle! In this tutorial, we'll learn about bundles, their super-powers, how to add services & routes and the best-practices to create the best bundle possible:

  • Anatomy of a Bundle
  • Bundles vs Libraries
  • Building a bundle inside your app
  • DependencyExtensions to add Services
  • Complex Service configuration: Definitions & compiler passes
  • Allowing config via a Configuration class
  • Private services
  • Routing & other Configuration
  • Creating a Recipe
  • Registering your bundle with Packagist
  • Handling Releases
  • README!

Not only will you be able to create your own bundle, but we'll learn a lot along the way about how all bundles in the Symfony world work!


Your Guides

Ryan Weaver

Questions? Conversation?

  • 2018-04-18 Radoje Albijanic

    I enjoyed so much watching this tutorial. Awesome!

  • 2018-04-12 weaverryan

    Hey Rafael!

    Bah! Unfortunately, that's the one thing that I did *not* cover in this tutorial.... in part because it's super tricky to record properly. But if you have any questions, let us know. My advice is this: your bundle may NOT need a recipe at all - many do not. You only need a recipe if your bundle requires some configuration or other files (e.g. the Twig recipe creates a templates/ directory). A recipe is basically "automating" the README. So if your README says "Do X, then create file Y", these are great things for the recipe :). And mostly, recipes are quite simple: you include files that you would like copied into the user's project.

    Cheers!

  • 2018-04-07 Rafael

    Hey, Is it going to cover how to create and publish sf flex recipe for this custom bundle? it would be nice!

  • 2018-04-06 Victor Bocharsky

    Hi Virginie,

    Really? I could find this course by "Symfony Bundle" keyword, see https://knpuniversity.com/s... . I wonder what keywords you searched for. Well, yes, Symfony 4 is bundle-less, but it means you should avoid creating bundles in the src/ folder of your project, but third-party bundles are still valid. And this screencast is not about creating project bundles but third-party bundles. In shorts, you create a bundle only when you need to share some code between projects. And this course probably will be in the Symfony 4 track because, well, we're using Symfony components v4.0 in this course. But most of the information we show in this course is valid for Symfony 3 as well, of course, if we're talking about sharable third-party bundles.

    Cheers!

  • 2018-04-06 Virginie Burlot

    Hi !
    I see that this course is currently in progress, and I wonder, will it be implemented into the SF3 or 4 Track ? I know that there are no more bundle into SF4, so, does it concern SF3 exclusively ?
    Also, I must say that I can't find this course into your searching tool. I only found it while going through the "Courses updates" through my profile.