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!

  • 2020-05-20 Victor Bocharsky

    Hey Niki,

    I know very little about ionCube, but yes, I suppose it should be possible as long as you warm up the cache before encoding. Basically, Symfony app should generate all the necessary cache and compile all necessary files during the cache:warmup command. After this, you can run Symfony app on read-only filesystem and it should just work. Of course, it also depend on you and your code. I suppose you should avoid writing to the filesystem in your code, only read operations, or probably use a different cache providers like Memcache or Redis, etc.

    I hope this helps, unfortunately, I can't say more about it.

    Cheers!

  • 2020-05-19 Niki

    Hi,
    Is it possible to encode a symfony project with ionCube without breaking it?

  • 2020-03-18 Victor Bocharsky

    Hey Mickael!

    Glad you was able to figure it out yourself! Ryan *just* started using this new terminal theme - he's using zsh with ohmyzsh. Inside ohmyzsh, he's using the "af-magic" theme with some customizations. Here's my custom theme file - https://gist.github.com/wea... - it's the "af-magic" theme but (mostly) with a few features *removed* to keep his screen simpler.

    I hope that helps :)

    Cheers!

  • 2020-03-17 Mickaël Andrieu

    Finally got something working :)

    # ~/.zshrc
    # <<< dotted line between command >>>
    setopt promptsubst
    PS1=$'%F{250}${(r:$COLUMNS::╌:)}%f'$PS1

  • 2020-03-17 Mickaël Andrieu

    Hi Ryan, totaly unrelated question ... but how do you do to display a dotted line after each instruction in your command line interface ?

    This is super useful !

  • 2020-03-15 weaverryan

    Hey Jason Aller!

    Excellent question! It is mostly to introduce concepts little-by-little. By showing php bin/console, it's easy to show that you're just executing a normal, boring, physical file. But symfony console looks a bit more "magical", even though it's technically a lot more useful (because you can manage PHP versions through it, run commands un "tunneled" SymfonyCloud environments etc). I'm planning to introduce doing more things with the symfony command little-by-little - it'll especially be important when we talk about databases.

    Cheers!

  • 2020-03-12 Jason Aller

    In Chapter 01 the Symfony executable is downloaded. Is there a reason why in this chapter php bin/console is used instead of symfony console other than that it might be shorter to type?