Archived video

This video is archived and won't be updated. We're keeping it online for now as a courtesy.

Alternate resources: 

Symfony Bundles

Video loading...

  • 0:00
    Starting with Symfony2 Symfony Bundles
  • 0:07
    with Leanna Pelham
  • 0:09
    Bundles are a hipster buzzword in the Symfony world.
  • 0:12
    Yeah, they're cool, I guess,
  • 0:14
    but we really deserve all the credit.
  • 0:16
    A bundle is just a place for us to put our hard-earned code.
  • 0:20
    We might make an event bundle directory for that feature
  • 0:23
    and a user bundle where we build the registration and login stuff.
  • 0:27
    We'll put anything and everything into a bundle-- PHP
  • 0:30
    code, config, templates, CSS, and cats.
  • 0:35
    OK, not cats.
  • 0:37
    We can also put other people's bundles into our project.
  • 0:41
    A bundle in Symfony is similar to a plugin in other systems
  • 0:44
    but, you know, way more hipster.
  • 0:48
    Yes, we can create bundles manually,
  • 0:51
    but I'd rather have someone else do it for me.
  • 0:55
    Meet Console, a magic executable file in the app directory.
  • 1:00
    Run it to see all of the tricks it knows.
  • 1:03
    Whoa, all those green words are different console commands,
  • 1:07
    including a lot of things that help you
  • 1:09
    work with the database and debug.
  • 1:11
    I like tools as much as any programmer geek,
  • 1:14
    so we'll use a lot of these over time.
  • 1:18
    For now, run the generate bundle command.
  • 1:24
    For the bundle namespace, type Yoda/EventBundle.
  • 1:27
    A bundle namespace always has two parts, a vendor name
  • 1:31
    and a name describing the bundle.
  • 1:34
    In honor of the Jedi master, we'll use Yoda for the first part
  • 1:37
    and EventBundle for our second.
  • 1:39
    Unless you also work for Yoda, you'll probably
  • 1:42
    use your company or project name instead.
  • 1:45
    Keep these as short as possible to save typing later.
  • 1:50
    Next, it wants a nickname for our bundle.
  • 1:53
    We're going to be writing this a lot,
  • 1:55
    and let's face it-- we're busy people.
  • 1:57
    So let's choose something short, like EventBundle.
  • 2:00
    The only rule is that it ends with Bundle.
  • 2:04
    Use the target default directory, but choose
  • 2:06
    yml as the configuration format.
  • 2:09
    You'll just have to trust me on this part.
  • 2:11
    We'll check out the annotation configuration format later.
  • 2:15
    For the rest of the questions, just hit the Enter key wildly.
  • 2:19
    And once the console-gnomes are finished,
  • 2:21
    we have a brand new bundle.
  • 2:23
    This did exactly three things for us.
  • 2:26
    First, it made an src/Yoda/EventBundle directory
  • 2:29
    with some sample bundle files.
  • 2:32
    Second, it plugged our bundle into the motherboard
  • 2:34
    by adding a line in the AppKernel class.
  • 2:37
    Third, it added a line to the routing.yml file
  • 2:40
    that imprints routes from the bundle.
  • 2:43
    Now contain your excitement-- we're about 30
  • 2:45
    seconds from talking about this part.
  • 2:48
    But I want to share a quick secret first.
  • 2:51
    If you're using PHPStorm, like I am, I
  • 2:53
    need you to download an awesome Symfony plugin.
  • 2:56
    For everyone else, this is totally not needed.
  • 2:59
    It just adds some shortcuts.
  • 3:14
    Once it's installed, you need to activate it.
  • 3:22
    And now we're super-charged with a ton of Symfony-specific help.
  • 3:25
    You'll see this along the way.
Loading ...

Symfony Bundles

Loading...

A bundle is just a place for us to store related code. We might make an EventBundle directory for that feature, and a UserBundle where we build the registration and login stuff. You can put anything and everything into a bundle: PHP code, config, templates, CSS and cats. You can also put other people’s bundles into your project. A bundle in Symfony is similar to a plugin in other systems. In this lesson you're going to create your first bundle, an EventBundle, using the Symfony app console.

Downloads: 
Log in or sign up to download companion files.

Additional resources:
There are no resources for this video. If you believe there should be, please contact us.