Symfony 4: Debugging and Packs

Video loading...

  • 0:03
    Symfony: 4 Debugging and Packs with Ryan Weaver
  • 0:07
    Symfony has even more debugging tools.
  • 0:11
    The easiest way to get all of them, is to find your terminal
  • 0:15
    and run composer require debug --dev
  • 0:20
    Find your browser,
  • 0:21
    surf back to symfony.sh and search for debug.
  • 0:27
    So the debug alias will actually install
  • 0:31
    a package called symfony/debug-pack.
  • 0:36
    So, what’s a pack?
  • 0:39
    Click to look at the package details and then go to its GitHub repository.
  • 0:44
    Whoa!
  • 0:45
    It’s just a single file,
  • 0:48
    composer.json.
  • 0:50
    Inside, it requires 6 other libraries.
  • 0:55
    Sometimes you’re going to want to install
  • 0:57
    several packages at once related to 1 feature.
  • 1:02
    To make that easy, Symfony has a number of packs
  • 1:06
    and their whole purpose is to give you 1 easy package
  • 1:10
    that actually installs several other libraries.
  • 1:15
    In this case, composer require debug
  • 1:17
    will install monolog,
  • 1:19
    a logging library, phpunit-bridge for testing
  • 1:22
    and even the profiler-pack that we already installed earlier.
  • 1:28
    If you go back to the terminal, yep!
  • 1:31
    It downloaded all those libraries and configured a few recipes
  • 1:37
    and check this out.
  • 1:39
    Refresh.
  • 1:40
    Hey, our Twig dump got prettier.
  • 1:45
    The debug pack integrated everything together even better.
  • 1:50
    Go back to your Twig template and remove that dump.
  • 1:53
    Then open composer.json.
  • 1:57
    We just installed 2 packs.
  • 1:59
    The debug-pack and the profiler-pack.
  • 2:02
    And we now know that the debug-pack
  • 2:05
    is actually a collection of about 6 libraries.
  • 2:09
    But, packs have a disadvantage.
  • 2:12
    A dark side.
  • 2:14
    What if you wanted to control
  • 2:16
    the version of just 1 of these libraries?
  • 2:20
    Or, what if you wanted most of these libraries
  • 2:23
    but you didn’t want, for example, the phpunit-bridge?
  • 2:28
    Well, right now, there’s no way to do that.
  • 2:32
    All we have is this 1 debug-pack line.
  • 2:37
    Don’t worry, brave space traveler!
  • 2:39
    Just unpack the pack. Yep.
  • 2:42
    At your terminal,
  • 2:43
    run, composer unpack debug.
  • 2:48
    The unpack command that comes from Symfony Flex.
  • 2:52
    And interesting,
  • 2:54
    all it says is removing symfony/debug-pack.
  • 2:59
    But if you look at your composer.json,
  • 3:03
    it did remove symfony/debug-pack,
  • 3:06
    but it replaced it with the 6 libraries from that pack.
  • 3:12
    We can now control the versions
  • 3:14
    or even remove individual libraries, if we don’t want them.
  • 3:19
    That is the power of packs.

Symfony 4: Debugging and Packs

Loading...

In this tutorial, we'll install and explore debug-pack, a Symfony debugging package that includes Monolog (a logging library), phpunit-bridge (for testing), and even the profiler-pack that we already installed in a previous lesson.

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