Learning Symfony 2

There are some good friends that has recommend me to learn Symfony 2. I’ve been programming with Zend Framework (not even version two) and with our own framework at VisualDNA, so I was eager to see how the frameworks ecosystem has evolved during this 2 or 3 years that I haven’t been keeping myself updated.

I’ve done the first part of the learning stage, which consists in information gathering. In this post I only wanted to aggregate some useful resources I’ve found and that I still need to consume myself.

Reading

This is basically browsing on the Symfony 2 official documentation. It’s pretty well organised and structured.

Not much going on here, really, but I think it’s interesting to spend some time having a first read about what the official documentation says.

Practising

On the “getting started” you have already checkout and played a bit with the code, but there are two good blog posts / tutorials that look interesting:

Doing this tutorials looks really interesting but the real way to learn is to try it yourself without looking at those. Probably, think about something you have wanting to do for some time and just do it using Symfony 2, that will be IMO the best way to learn.

Videos

Finally, there is some good amount of knowledge on the Internet regarding to video material. Talks from the “Symfony Live” in Paris or San Francisco, or many other conferences that has been happening recently. Here they are:

That’s all for me. If you have any useful resource where you can learn from, please, leave a comment and I will be very happy to update this list of resources.

Tmux cheat sheet

I’m getting started using tmux, and I’ve done my own “cheat sheet”. It’s useful to do that so you write harder in your memory and you will always remember the place to look at the commands, which will be this page :) !

For those who don’t know tmux, it’s a “terminal multiplexor”, like screen (which is another similar tool). It allows user to acces multiple separated terminal sessions. Because I work remotely , this tools are really useful for me and saves a me a lot of pain. The main benefits of using this kind of tools are:

  • I can have all the time my session saved, and if I loose connection or my terminal hangs I will be able to restore it.
  • I can put multiple “panes” into the view, dividing horizontally, vertically, etc.
  • I can share session with my colleagues and we can “pair program” remotely.

Basic (outside tmux)

// create session
tmux new -s {name}

// attach
tmux attach -t {name}

// kill
tmux kill-session -t {name}

// list all sessions
tmux ls

Modes (once you are inside tmux)

Ctrl+a c        # create a new window
Ctrl+a d        # detach current client
Ctrl+a x        # kill a pane or window

Ctrl+a "        # split pane horizontally
Ctrl+a %        # split pane vertically
Ctrl+a {        # move to the left pane
Ctrl+a }        # move to the right pane
Ctrl+a o        # switch to the next pane
Ctrl+a q        # show pane numbers (used to switch between panes)
Ctrl+a space    # toggle between pane layouts

Ctrl+a j (or k) # move up or down a pane
Ctrl+a h (or l) # move left or right a pane

Ctrl+a ,        # name the window (test, vim, console, log, etc.)
Ctrl+a l        # move to previously selected window
Ctrl+a n        # move to the next window
Ctrl+a p        # move to the previous window
Ctrl+a w        # list all windows
Ctrl+a {n}      # move to specified window number
Ctrl+a ?        # list all keybindings

Ctrl+a [        # enter copy mode

Finally, let me say I’ve updated my .tmux.conf. This is the content:

# act like vim
setw -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+

# act like GNU screen
unbind C-b
set -g prefix C-a

# look good
set -g default-terminal "screen-256color"

My first Katayuno

Coding Katas are small problems from a known domain, with the objective of practise basic programming elements and TDD.

Katayunos are the combination of “Coding Katas” and “Desayunos” (which means breakfast in Spanish). It consists on sitting in pairs, in front of a laptop, choose one of the available katas and programming language and have breakfast while working on the given problem practising TDD and thinking about the best approach to solve the problem.

Well, this weekend I’ve been involved on my first Katayuno experience, at Softonic offices. The practised kata was KataBankOCR, where we are given with an ASCI numbers and we have to transform that into a String, not very complex but it had an interesting point into the test.

At the first iteration, we were tackling the problem wrong. We spend some time trying to validate the input and where a bit slow because our strict state (RED – GREEN – REFACTOR) of TDD work-flow. At the end of the first iteration we were discussing about how much we have to cover with the test. On that problem, we can’t test much more than “for a given input” which is the “expected output”.

What you think about testing private methods?

Obviously you can’t test private methods straight away, but you can work around that. However, we agree that doing that is not a good test case. The main reason is that we want to test the problem, not our concrete solution about the problem. The point is that at the end of the exercise, we could switch tests and our code shall keep passing both tests.    

On the second iteration we got it right (in PHP) and in the third and last iteration I had the chance to play with Jasmine, a test library for Javascript (pretty cool stuff). I’ve uploaded my code into Github. Pretty good exercise overall, and felt like I’ve learned and enjoyed.