Changing the default Command on Symfony Console Component

A new feature that I purposed to Symfony Console Component and developed at SymfonyCon Hack Day was merged this week and will be available since version 2.5+.

The feature will allow you to change the default Command when you are creating Console Applications.

Usage

Before this if you don’t provide the command you want to execute it executes the ListCommand by default, with this feature you are now able to change that behavior by simple setting the Command you want to be the default. Let’s see how you can do it:


// src/Acme/Command/HelloWorldCommand.php

namespace Acme\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class HelloWorldCommand extends Command
{
    protected function configure()
    {
        $this->setName('hello:world')
            ->setDescription('Outputs \'Hello World\'');
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('Hello World');
    }
}

Now that we have our HelloWorldCommand let’s create the application and make it the default command:


// application.php

use Acme\Command\HelloWorldCommand;
use Symfony\Component\Console\Application;

$command = new HelloWorldCommand();
$application = new Application();
$application->add($command);
$application->setDefaultCommand($command->getName());
$application->run();

Let’s execute it:

$ php application.php
$ Hello World

Simple, if you want to list all commands you just need to do php app.php list.

Limitation

The default command does not accept arguments only options.

Note: I added a new entry to Symfony Console Component documentation that should be is available in the Symfony website soon.

Status

Today was a sad day. Eusébio da Silva Ferreira died at age of 71. The “King”, “Pantera Negra” and legend of Sport Lisboa e Benfica and Portugal. You will be missed but you will always be remembered. Thank you for everything. Rest In Peace Eusébio.

2013 was an amazing Year!

2013 was amazing!

2013 is reaching its end and it’s the time to look back and see what goals I achieved and it’s the time to think about new ones for 2014.

This was the year where I moved to a new professional project (Guestcentric Systems), was the affirmation of the phplx UG, was my first time speaking in international conferences (and did it 3 times this year), opensourced two libraries - Mailchimp API Connector and Eventbrite API Connector, built the phplx prize raffle CLI application, started to contribute more to opensource – but not as much as I would like too. Traveled to Paris and Warsaw. Blogged 20 posts (including this one) but not much about technical aspects as I would like.

In terms of my personal goal, I didn’t reach my goal of losing weight but at least I reached my goal of spending a little more time with my family and specially my kid (need to improve this next year)!

What is coming for 2014…

In terms of phplx I hope that the community continues strong, growing and doing the usually monthly meetups. In terms of new events related with the PHP in Portugal, probably we will have some news for 2014 :)

For opensource my goals is to be more active and contribute more – in terms of code, documentation or by helping the community. Also I do plan to attendee more conferences next year and if possible as a Speaker!

I will try next year to post more topics about technical aspects with tips and tricks, this year I didn’t have so much time for it but for next year I really want to improve this.

My personal goals for next year will be to lose weight (at least 25kg), have more time for myself and family.

I want to thanks to every person I met this year and everyone who helped me in a way or another in being a better person/professional.

Wish you all a Happy New Year and an AMAZING 2014!

SymfonyCon 2013 was STUNNING!

SymfonyCon 2013

Finally I had some time to write about SymfonyCon.

The first SymfonyCon took place in Warsaw (December 10th-14th) and was held at the Westin Warsaw hotel.

This was my second PHP’s conference. Conferences are fantastic not only because the talks and what you learn from them – but also it gives you the opportunity to meet the people that you usually follows on twitter or/and github.

The Conference

As an attendee IMHO the schedule was very well planned and was very hard – for me – to choose which track to go – since both had topics that I wanted to hear about. I could say something about each talk I attended but I do think the best place is to go to the joind.in page of the conference and see all the feedback from attendees and grab the slides until the videos are not online in the SensioLabs’s channel on youtube.

As a speaker it was an amazing experience – my talk was about How to build Console Applications. For me was a pleasure to be part of it and also very rewarding.

The Hacking Day

Me and Luis Cordova helped Anne-Sophie on the organization of the Hacking Day. The official hour to start was at 10:00 AM but people started arriving before 9:00 AM. We had ~150 people hacking together and the end result was impressive more than 25 PR created! Thanks everyone who contributed!

SymfonyCon Hacking Day

Photo by pulpmedia_at

The Socials

Speakers Dinner

No much to say. Great restaurant, fantastic people and delicious food!

Speakers Dinner

Jeopardy

It was my first time, so I didn’t know what jeopardy was about. Basically It’s a quiz show where the presenter (Jeremy Mikola) picked some topics about the community, conference, etc and then ask the audience for players (about 6 people) and then the goal is the players to guess what is the question instead of the answer. Was pretty fun. specially when the game crashes and no one got points on that round!

Jeremy Mikola ready for Jeopardy

Jeremy Mikola getting ready for Jeopardy

SensioLabs Insight Party

The party was in the Hotel and was cool see everybody wearing the same t-shirts. The music was cool and we had free beer/wine and food! A big thanks to SensioLabs Insight for the awesome party!

SymfonyCon SensioLabs Insight Party

Symfony AWARDS ceremony

IMO this is one of the best ways to recognize the people that contributes to the community and was nice to see who the community picked for each category! You can see the list of the winners of the awards - community and business - here.

Karaoke

Jeremy Mikola was the man in charge to pick a bar with karaoke. He did it very well, besides the bar have all tables reserved we got about ~40 people in it, it was packed but was very funny.

SymfonyCon Karaoke Party

Photo by karolsojko

Thanks

Thanks to SensioLabs team for the amazing conference and also for let me be part of it. A special thanks to Anne-Sophie for her amazing work organizing the conference – you did it very well! Congrats.

Photos

Here is a list of places I found some pictures of the conference:

See you in Madrid!

How to build Console Applications @ SymfonyCon 2013

This talk was presented at SymfonyCon 2013 in Warsaw.

Abstract of How to Build Console Applications

In some cases you feel the need to have some specific command-line commands for deployment, testing some code or do any other specific task and you usually use shell script to do it.

Why not use Symfony2 Console component ? You can easily build your own commands and interact with other bundles/components.

The Symfony2 Console component is a tool that gives you to build in a simple and easy way console applications.

This talk will focus on how you can simple build an Console applications and how you can interact with other bundles/components.

Slides

If you attendee to this talk please don’t forget to rate and give some feedback at joind.in!

Source Code

You can download it from my repository in github.

Also if you want to have a look at the source code of the phplx prize raffle Console Application it is hosted on github in a public repository.

Photos

Daniel Gomes @ SymfonyCon 2013

Photo by @bojanpejic

One year of phplx

phplx banner

One year ago…

Was exactly one year ago - December 6, 2012 – when the first phplx meetup happened. The first surprise we had was that the meetup sold out in less than 1 hour. We didn’t expect that happened so fast, for us was a win. For the first meetup we had a lot of sponsors – Flag, Tomorrow Today, Jetbrains, Sauce Labs, O’Reilly and Geeklist – and also three talks, three speakers and about 70 attendees! At the end the feedback from attendees was fantastic and we got some suggestions to improve, saying this, what could we ask more?

Today’s we can say that we reached lots of goals and some of them we didn’t expect at all. Tomorrow is the phplx anniversary meetup and also the last of 2013, we planned a full day event with talks and hacking to celebrate the 1st of many birthdays (we hope) of phplx! Note: the event is already sold out.

A bit more of history

Before the first meetup, more or less 3 months earlier, I started my idea of running a PHP UG (user group) – in Lisbon, Portugal – in a regular basis.

The goal I had in mind was simple – gather the PHP community monthly to share knowledge, experiences and to hang out – and this is the same goal we have today.

But everything got started when I thankfully attended to LXJS 2012 - and you ask – what the hell is a javascript conference related to PHP? The answer is simple, was there where I met Samuel Gordalina and we end up founding phplx, also I met other people that comes regularly to the phplx meetups. After that we had two organization meetings with people interested in the initiative – at Irish Pub in Cais do Sodré – to define the name of the UG, the structure of the meetups and other related things.

It took off and we started with three organizers – me, Samuel and Francisco Costa - and two volunteers - Benjamim Alves,  Francisco Almeida.

Today some of them left the organization, some had new projects to work on others don’t have time. Now we are four organizing – me, Samuel, Luís Santos and Ricardo Melo - and we welcome anyone who wants to participate in the organization of phplx – if you want to help just ping us.

Regardless who is now organizing the phplx meetups, everybody should celebrate today’s day and we are all to be congratulated for another goal reached! Happy birthday phplx.

The future

At least we hope next year to be better or equal than the past one. We are very thankful to everyone that makes phplx happen, organizers, sponsors but specially to speakers and attendees without them we wouldn’t have meetups.

Next year we will try to maintain the same regularity regarding the meetups and also try to do more drinkups. We also have some plans for other events but we will only share more information when we have it!

There are two things I would like to see happening next year with the PHP portuguese community.The first one is people step up to give talks, is always difficult to find someone to speak. The second one, depends on the first one, I would love to see more Portugueses giving talks at International Conferences! It’s not that hard, you just need to practice and phplx is a good start.

We would love to see other people taking this initiative off – by creating more php user groups – in others portuguese cities like Porto, Faro, Coimbra, you name it. If you want to do it let us know and we will help as much as we can to get things off the ground. ;)

If you have any suggestion or ideas please share with us! We would love to hear them!

Sponsors & partners

We are very thankful to all our sponsors and partners we had and to the ones that still with us. Regardless the sponsorship level without them probably phplx wouldn’t happen, or at least wouldn’t happen in the same conditions.

So in name of the phplx team we want to thank them all - FlagSapoMicrosoftServergroveGithubO’ReillyPTispJetbrainsSauce LabsTravis CIGeeklistTomorrow TodayUniPlacesIEEE ISCTE IUL Students branchNomad PHPLisbon MongoDB UGMongoDB formerly 10gen and Active Media  - the order has no meaning.

Finishing with some statistics

One year of phplx in numbers:

  • Number of meetups: 11
  • Average attendance per meetup: 34
  • Total number of speakers: 15
  • Total number of talks: 26
  • Number of drinkups: 1
  • Followers on Twitter: 121
  • Members on Facebook group: 250
  • Google+ followers: 78
  • Meetup.com members: 114
  • Total number of sponsors/partners: 18
  • Youtube channel (since end of August)
    • subscribers: 33
    • videos published: 13 (October and November meetups are in the queue)
    • total views: 1060
    • estimated minutes visualized: 2404
    • talk with most views and minutes viewed: MongoDB: Indexing and Query Optimization
  • Website
    • total page views: 6648
    • total visitors: 4496
    • total unique visitors: 2613
    • total countries: 65

ZendCon Europe 2013 was an amazing experience

The first Zend Conference in Europe named ZendCon Europe

ZendCon is one of the largest, if not the largest, PHP conference in the world and this year took place in Paris the first European edition (18-20 November 2013). It was a three days conference, the first day was dedicated to tutorials and the remaining days to sessions.

My perspective as an attendee

For me the conference was very well organized.The venue was fantastic, very comfortable, good food, the wifi was good besides some issues, the social party was very cool and it made me remember my childhood when I played a lot arcade machines :)

The talks I attended they were really good, some topics I already knew before but it is always great to hear it from others to learn new perspectives and you always end learning something you don’t knew. I could put here more information about the talks but I do think the best source is the joind.in page of the conference.

Also was good to understand and see what is the position of Zend for the present/future. It’s all about API-Centric and mobile first approach, continuous deployment and cloud services.

One thing that was less positive for me was the fact that the conference had 4 tracks and also an unconf and no recording talks. I am saying that because I had some talks that collided and couldn’t see the other one afterwards. What I would suggest for next edition is to record the talks, that way attendees would have the opportunity to watch the talks that collided later :)

My perspective as a speaker

Daniel Gomes ZendCon Europe Badge

That was my first time as a speaker in an International Conference outside Portugal.

For me was a privilege to be part of the first ZendCon in Europe and to be selected to give a tutorial - A LAMP environment from the ground up with Vagrant and Puppet -and also a talkConsole Applications made easy.

I was a bit worried about the workshop because it needed a good wifi connection for attendees but everything went well. Besides that the feedback I got from attendees was very good and got some ideas to improve both – the workshop and the talk.

The organization was fantastic and always available for help.

Summing up

A well organized conference. Great contents and a very good diversity of topics. Lots of networking.

Congratulations to Zend and NBS System for the awesome conference, fantastic job! Hope see you next year!

Console Applications made easy @ ZendCon Europe 2013

This talk was presented at ZendCon Europe 2013.

Abstract of Console Applications made easy

In some cases you feel the need to have some specific command-line commands for deployment, testing some code or do any other specific task.

The Symfony2 Console component is a tool that gives you a simple and easy way to build a console application with your own command-line commands. This talk is an introduction to the Console component and a walkthrough on how to use it in an effective way.

Slides

If you attendee to this talk please don’t forget to rate and give some feedback at joind.in!

Source Code

You can download it from my repository in github.

Also if you want to have a look at the source code of the phplx prize raffle Console Application it is hosted on github in a public repository.

Photos

Console Applications made easy | ZendCon Europe

Photo by @BrettPXL