The Lovely bin/console Tool

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

Let's commit our progress so far. I'll clear the screen and run:

git status

Interesting: there are a few new files here that I didn't create. Don't worry: we're going to talk about that exactly in the next chapter. Add everything with:

git add .

Normally... this command can be dangerous - we might accidentally add some files that we don't want to commit! Fortunately, our project came with a pre-filled .gitignore file which ignores the important stuff, like vendor/ and some other paths we'll talk about later. For example, var/ holds cache and log files. The point is, Symfony has our back.

Commit with:

git commit -m "we are ROCKING this Symfony thing"

Hello bin/console Command

You can interact with your Symfony app in two different ways. The first is by loading a page in your browser. The second is with a handy command-line script called bin/console. At your terminal, run:

php bin/console

Woh! This command lists a bunch of different things you can do with it, including a lot of debugging tools. Now, just to demystify this a little, there is literally a bin/ directory in our app with a file called console inside. So this bin/console thing is not some global command that got installed on our system: we are literally executing a physical PHP file.

The bin/console command can do many things - and we'll discover my favorite features along the way. For example, want to see a list of every route in your app? Run:

php bin/console debug:router

Yep! There are our two routes... plus another one that Symfony adds automatically during development.

The bin/console tool already contains many useful commands like this. But the list of commands it supports is not static. New commands can be added by us... or by new packages that we install into our project. That's my "not-so-subtle" foreshadowing.

Next: let's talk about Symfony Flex, Composer aliases and the recipes system. Basically, the tools that makes Symfony truly unique.

Leave a comment!

What PHP libraries does this tutorial use?

// composer.json
    "require": {
        "php": "^7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "easycorp/easy-log-handler": "^1.0.7", // v1.0.9
        "sensio/framework-extra-bundle": "^5.5", // v5.5.3
        "symfony/asset": "5.0.*", // v5.0.5
        "symfony/console": "5.0.*", // v5.0.4
        "symfony/debug-bundle": "5.0.*", // v5.0.4
        "symfony/dotenv": "5.0.*", // v5.0.4
        "symfony/flex": "^1.3.1", // v1.9.10
        "symfony/framework-bundle": "5.0.*", // v5.0.4
        "symfony/monolog-bundle": "^3.0", // v3.5.0
        "symfony/profiler-pack": "*", // v1.0.4
        "symfony/twig-pack": "^1.0", // v1.0.0
        "symfony/var-dumper": "5.0.*", // v5.0.4
        "symfony/webpack-encore-bundle": "^1.7", // v1.7.3
        "symfony/yaml": "5.0.*" // v5.0.4
    "require-dev": {
        "symfony/profiler-pack": "^1.0" // v1.0.4