Mocking Symfony Container services in Behat scenarios with Mockery

Mocking objects in unit tests is pretty straight forward as every object used in a test case is usually created in a scope of one test class. In functional tests it's a bit harder since we either don't have full control over objects being created or it's simply too laborious to mock half the framework. Instead of functional tests I'm using Behat. In the context of this blog post it satisfies the same need - verifies the external behavior of an application.

Fixing failing Behat scenarios in large suites

In projects I currently work on I'm taking the BDD approach really seriously. In one of my Symfony2 projects I ended up with quite a lot of Behat features and scenarios which one day started failing on the integration server. The problem was in MySQL returning "too many connections" response.

Managing object creation in PHP with the Symfony2 Dependency Injection component

Symfony's DependencyInjection component is a PHP implementation of a Service Container, or as others like to call it, a Dependency Injection Container (DIC). The component also provides useful tools for handling service definitions, like XML loaders or dumpers.

Symfony 2.0 released!

Today, 28th of July 2011, Symfony 2 was announced stable. We've been waiting long but it was worth it!

Finding files and directories in PHP with Symfony2 Finder component

Symfony Finder component makes the task of finding files and directories less tedious. It supports filtering by name, pattern, size, date of modification and few other criteria. As a result we get objects of class SplFileInfo. It offers convenient way of retrieving file and directory details.

Creating parametrized command line scripts in PHP with Symfony2 Console component

Symfony Console component enables us to create commands in PHP. It does all the nasty work of handling input and output.

Autoloading classes in an any PHP project with Symfony2 ClassLoader component

Symfony ClassLoader component is a PSR-0 standard compliant PHP class autoloader. It's not only able to load namespaced code but also supports old-school PEAR standards (also used by Zend Framework). It's a perfect class loading tool for most of PHP projects.

Setting up a PHP development environment with Nginx on Ubuntu 11.04

I already described how to prepare a PHP development environment with Nginx on Ubuntu 10.04. Ubuntu 11.04 (Natty Narwhal) simplifies the procedure a lot since php-fpm is available in the PHP 5.3 core. As I also managed to improve my Nginx configuration for PHP I decided to write on the subject again.

Nginx configuration for Symfony projects

Recent release of Nginx 1.0.0 triggered me to refresh my knowledge about its configuration options. There were quite some additions since I looked in the docs for the last time. New variables and directives let me to simplify my configuration for Symfony projects (both 1.x and 2).

Compiling doctrine in symfony 1.4

When profiling symfony 1.x applications hydrating Doctrine objects occurs to be one of the most time consuming operations. Recently I experienced something different. Loading ORM classes was one of the most expensive tasks. Usually such operations don't even show up during profiling.

Multistage deployment of Symfony applications with capifony

Capifony is a collection of Capistrano deployment recipes for both symfony and Symfony2 applications. Multistage is an extension for Capistrano which enables deployments to multiple servers with varying configurations or deployment procedures.

Things I like about the new Symfony2 Form Component

Forms Refactoring, the last big change and recently most awaited pull request for Symfony2, was finally finished last Sunday. The work is not fully done but it's ready for merge. Request is still waiting for approval and as soon as it's accepted (or rejected) we can expect a beta release.

Learning Symfony2 by Unit Testing (Contribute to Learn)

During the Hacking Day on the Symfony Live conference I decided to give it a try and write some unit tests for Symfony2. I'm a big fan of TDD for quite some time already and I recently became really interested in BDD. For sure I'm not new to unit testing. Still, I didn't expect that writing tests for an existing piece of software can be so much fun.What I also discovered is that writing unit tests for Symfony is a great way to learn its internals.

Symfony Live 2011

I'm writing this post on a way back from the second international Symfony Live conference. Nearly 500 developers arrived to Paris from all over the world to participate in this great event.

Doctrine2 and Symfony2

I continue exploring the Symfony2 framework. It's flexible enough to be used with any modern PHP ORM. However, as with everything in Symfony2, there are sensible defaults provided. In case of an ORM it's Doctrine2 bundle.

Just agile

Mike Cohn wrote a new blog post on his "Reflections on the 10 Years Since the Agile Manifesto". Especially one thing he mentions struck me.

Setting up a bleeding edge Symfony2 project

Symfony2 is not ready yet. Since the release is planned for March this year and I just can't wait any longer I started to play with it more seriously.I also want to know all those nitty-gritty details. Therefore I didn't go for sandbox and decided to generate a fresh project.

Heard in the Community (2010.08.15)

Munchkin is a series of tutorials showing how to build a PHP project with the best programming practices in mind. As Author says: "If you consider the average PHP world and average RPG, where the players are coders, then doing agile and TDD would definitely make you a power player who gets all the loot.". Not in all cases I would use the same tools but it's not about copying the author. Tools doesn't matter as much as the proper approach he tries to teach us.

Heard in the Community (2010.08.08)

Jonathan Wage wrote on his blog about Doctrine Annotations Library. It's used in Doctrine2 ORM for mapping information specified in doc-blocks. I'm really excited about it, especially because it is an independent library. It makes it a perfect tool for meta-programming. I can't wait to put my hands on it!

Heard in the Community (2010.08.01)

Symfony2 development moves forward quickly. Last week the API documentation was generated and put online by Fabien Potencier. Also, the translation process is now described so translators can start contributing.

Symfony meets APC (Alternative PHP Cache)

Up to last week I was exclusively an XCache user if we talk about PHP accelerators. Recently I needed to use APC with a symfony application. As symfony offers nice APC integration it went quite smooth.

Heard in the Community (2010.07.25)

"Heard in the Community" series aims to wrap up news from the PHP, symfony and other communities I find interesting and follow.

PostgreSQL installation in Ubuntu 10.04

PostgreSQL is a powerful and reliable object-relational database system. It's a great alternative for MySQL. It is as easy to set up, performs better and offers far more features.

MySQL installation in Ubuntu 10.04

MySQL is one of the most popular relational database systems which is widely used with PHP applications. It's relatively easy to set up and use. Here's a quick guide of how to install and configure MySQL in the newest release of Ubuntu.

Getting a class and method overview in vim with the TagList plugin

TagList plugin for vim allows you to view list of classes, methods, variables, constants and other tags from index file generated by exuberant ctags. TagList shows tags in a context of files you edit and groups them by type. You can jump to a chosen tag, open it in a new tab or window and do many other useful things.

The best vim cheat sheet ever!

Here's an unique graphical cheat sheet I found on ViEmu website. They also have a tutorial based on it. Really useful stuff. Not only for a vim newbie!

Reply to PHP 5.3 and the Future

Mark Evans wrote on his blog interesting post about PHP 5.3 and the Future. I guess the main concern here is similar we used to have with PHP4 to PHP5 migration (GoPHP5 campaign). Mark raised three questions to the community which I'd like to reply to.

Jumping to a class, function and variable definitions in vim with exuberant ctags

Exuberant ctags make it possible to jump to the definition of a class, method, variable and any other language object in vim. Tool is able to generate an index file (a.k.a tag file) for one of 41 supported programming languages. Index can be used by editors like vim to quickly find related keyword.

Exploring files and directories in vim with the NERD tree plugin

Exploring, opening, switching, renaming, moving files and directories are common tasks performed during coding. In IDEs it is usually achieved with some kind of filesystem explorer. In vim I preffer to use the NERD tree plugin.

Ubuntu 10.04 Lucid Lynx

Ubuntu 10.04 Lucid Lynx was released two days ago. Yesterday I've installed it on my laptop. As I used beta before I wasn't surprised with a stable release. I'm also not disappointed. It's just great!

Setting up a PHP development environment with nginx on Ubuntu 10.04

Nginx is a lightweight http, proxy and load balancing server. It's a serious alternative for a widely used apache. Most important advantages of nginx on a production environments are speed and small amount of memory it uses. In a development environment I really like the simple and flexible configuration. Here's a guide how to quickly prepare PHP development environment with nginx on Ubuntu 10.04 (Lucid Lynx).

Ubuntu One Music Store is public now

I'm writing this blog post while listening to the first song I bought just few minutes ago on Ubuntu One Music Store. It cost me 79 euro cents. Oh yes, Ubuntu One Music Store is public now!

Textile in vim - edit your text files with wiki markup

Textile is a simple markup language. It's used in CMS and wiki implementations (i.e. Redmine). I also like to use it while making notes in plain text files. Textile plugin for vim adds support for syntax highlighting, preview and html conversion of Textile documents.

Ubuntu 10.04 Lucid Lynx is just around the corner

Yesterday first beta of Ubuntu 10.04 was released. Its code name is Lucid Lynx. I decided to give it a try even if it's unstable. I upgraded my old desktop computer which was still running Ubuntu 9.04.

Blogged in 2009

2009 is the year I came back to blogging. To be honest I didn't write as much as I could or want to. One of my goals for 2010 is to increase quantity and quality of my blog posts.

Viewing svn diff result in vim

Some time ago I explained how to use colordiff to display svn diff's result in colors. You can do pretty the same with vim. It is specially useful when you have big amount of code to commit and it needs to be reviewed first. Vim makes navigating through it easier.

Frets on Fire - Guitar Hero in Ubuntu 9.10 (Karmic Koala)

I just played Frets on Fire, an amazing game which managed to absorb me enough to write this blog post. It doesn't happen to often. Frets on Fire is a Guitar Hero clone for PC (runs on Linux, Mac and Windows).

Chromium - Google Chrome in Ubuntu 9.10 (Karmic Koala)

Google Chrome doesn't support Linux based operating systems yet. However, it is made on Chromium which works on all major platforms. Chromium is an Open Source web browser with the same feature set as Google Chrome. Actually Google Chrome is based on Chromium. The only difference is the logo.

How to use TextMate like snippets in vim?

Snippet is a piece of text which can be pasted into the document. Parts of it can be parametrized or calculated while pasting. Snippets can increase your productivity by letting you to write common parts of code faster and without mistakes. One of the most famous snippet implementations is included in TextMate editor. In vim we have some of TextMate's snippet features bundled in snipMate script.

How to record a macro in vim?

Macro is a sequence of instructions performed as a one step. In programming it helps automating the repeatable tasks which makes them less boring and less error-prone. Instead of performing the same actions over and over again, it's better to record them as a macro. Once macro is saved it can be run as many times as needed. Vim as a one of most powerful editors has macro support built in.

Symphony CMS on nginx

I decided to give a Symphony CMS a try because of its XSLT templating system and structured approach in creating websites. As most of PHP applications it's running on apache out of the box. Since I preffer using nginx I've encountered small problems with the configuration.

Caching the websites with bash script and apache's .htaccess file

Recently I got a task to make a completely inefficient application usable enough to give the development team time for improvements. I didn't know the application and didn't have sufficient time to learn it. In that completely miserable moment I was left alone.

Viewing svn diff result in colors

svn diff allows us to see the changes made on the files in the subversion repository. However, its output is not always clear. We can improve our experience a bit by installing colordiff which wraps diff command and produces coloured output.

Chromium - Google Chrome in Ubuntu 9.04

Chromium is a project aiming to run Google Chrome web browser on Linux. Launchpad repositories deliver apt sources list for Ubuntu which enables us with an easy installation process like usual: add sources and authorization key, update package database and install the application.

Using SimpleXML with sfWebBrowser to parse html documents

sfWebBrowser is a class that emulates browser calls. It gives us nice object oriented interface to navigate through document structure in a programmed way. It can return response as SimpleXML which enables us to use xpath queries on the document being parsed. Unfortunately html pages are hardly ever XML valid documents. That's why in most cases sfWebBrowser rather throws and exception than returns something. Here is how we can write a workaround for it.

Put your stylesheets at the top and your scripts at the bottom

Putting the stylesheets at the top of your web page and moving the scripts to the bottom are only two of thirty four rules described in Best Practices for Speeding Up Your Website (by Yahoo). Following these two rules, however, can really decrease visible time of page rendering. I will present a simple solution to achieve this in symfony framework.

Looking at the website's source code

Most of the web programmers have some kind of deviation that tells them to look into the source code of the websites they visit. In many cases author planned to have nice indented output. In other cases author just didn't care.