Posts Tagged ‘symfony development’

Setting up a symfony project with PHPUnit on Hudson

October 26th, 2010

We are using Hudson now for several months as Continous Integration System. This short article describes how we have configured a hudson project for a symfony 1.4 project. I am assuming that the reader is already used to Hudson and knows how a normal project has to be configured.

PHPUnit is the test framework of our choice (surprise, surprise) and we are using the sfPHPUnit2Plugin for all our projects. If you do not now this plugin you may first read another post where the usage and features are described in detail.

All requirements in short:

* Hudson has to be installed
* Hudson plugin xUnit Plugin has to be installed
* the symfony project needs the sfPHPUnit2Plugin
* PHPUnit has to be installed on your test server

Ok, here the configuration steps of the hudson project:

1. Configure your project

Configure standard settings for a hudson project like source-code management settings or email notifications. Please check the official docs if you do not know how to handle this.

2. Add a shell build step

Building a symfony project in a test environment is pretty easy. With the help of some shell commands the project is completely configured and ready for testing. Those shell commands may be entered in the build step section of the hudson project. Defining the correct commands is the main part during the configuration process.

Our configuration looks like this:

1. cd $WORKSPACE/trunk
2. sh _deployment/install_test.sh
3. php symfony cc
4. php symfony phpunit:test-all –configuration –options=”–log-
5. junit=build/testresult_$BUILD_NUMBER.xml” cd build
6. ln -s -f testresult_$BUILD_NUMBER.xml currentTestResult.xml

1. Jump in the project root of the project
2. Install the project on the test server with the help of a internal shell script. This step includes for example the generation of the databases.yml.
3. Clear the symfony cache (always a good choice)
4. Run all PHPUnit tests including unit and functional tests. The test result is written in a jUnit compatible logfile (needed for the xUnit Plugin).
5. Jump in the build directory, which is internally used by Hudson
6. Symlink the latest testresult

3. Configure Post-Build-Action

After the xUnit Plugin is installed correctly, an additional PHPUnit Pattern field should be displayed in the post build action section. In this field has to be entered:

1 trunk/build/currentTestResult.xml

The options “Fail the build if test results were not updated this run” and “Delete temporary JUnit file” should be both checked.

The xUnit Plugin takes the currentTestResult.xml file, which was previously created with the help of the sfPHPUnit2Plugin and analyzes it. When everything works fine, you should be able to review the created test reports.

Here some screenshots how this result could look like.

Build history:

Trend graph of the test results:

You can find the original post here : http://dev.esl.eu/blog/category/symfony/

Interesting symfony plugins: sfSyncContentPlugin

June 21st, 2010

With the amount of plugins published in the symfony site, many great plugins get lost in the maze. With this series of posts, we would like to bring some attention to plugins we use every day or that we think are essential for any symfony developer.

sfSyncContentPlugin

Deploying symfony applications is always a key part of developing and maintaining websites that run on symfony. It is always a recommended practice to do development on a local environment or dedicated development server. It is also recommended to have a QA/staging server that is as close as possible to your production server. Using this well proven method you can spot problems and bugs before everybody else sees or experiences them, you know, those bugs that “only” happen in production, don’t tell me that it never happened to you, I won’t believe you.

Anyway, making changes in a live site is not only not recommended, it should never be done!

When developing and testing symfony applications, a lot of times you need to have a copy of the live data. Or you may have a staging server where you make changes before pushing them to a live site in a production server. symfony already provides a way to deploy code changes to a remote server, but what about uploaded and data files? And database content?

Since we discovered and started using it, we can’t live without thesfSyncContentPlugin plugin by Tom Boutell and Alex Gilbert, also developers ofApostrophe CMS. This plugin helps with all the tasks and needs described above. Using it is quite simple. All you need to do is define your servers in config/properties.ini like this:

[qa]
  host=qa.example.com
  port=22
  user=user
  dir=/var/www/mysite

[prod]
  host=www.example.com
  port=22
  user=user
  dir=/var/www/mysite

[staging]
  host=staging.example.com
  port=22
  user=user
  dir=/var/www/mysite

Make sure to use SSH keys to authenticate to your remote servers, so you don’t get asked again and again for passwords. Then just run the following symfony tasks:

# Migrate files and DB from development to qa
./symfony project:sync-content frontend dev to qa@qa

# Migrate files and DB to production (always make a backup of production before doing this!)
./symfony project:sync-content frontend dev to prod@prod

# Migrate files and DB from QA into development
./symfony project:sync-content frontend dev from prod@prod

Files and DB content are copied accordingly, almost magically. It saves so much time, but please make sure you understand and check the order that you apply in the symfony task. With the power this plugin provides, is very easy, by mistake, to overwrite production data, so again, always make a backup!

Developing Symfony with Eclipse

June 3rd, 2009

hi i found a great link for symfony developers.

Developing Symfony with Eclipse

The Symfoclipse-Plugin: Currently in Version 1.2.1 this is the first Symfony-Plugin for Eclipse. Some glitches and rough edges but pretty usefull. It allows you to run common commands like freeze, cc and so on for a symfony project. First support for YAML is also available. The plugin is available from: http://noy.cc/symfoclipse

from ,

hiren sejpal :)

Upgrade Symfony Projects to 1.1 and 1.2

May 1st, 2009

With your ongoing projects if you want to change the branch of symfony from 1.0 to 1.1 or from 1.1 to 1.2, here are links to describe how

The document on the symfony official site provides the details about what changes made in 1.1 and 1.2 branches, and what to be done to upgrade your projects

[1]   Upgrading Projects from 1.0 to 1.1

http://trac.symfony-project.org/browser/branches/1.2/UPGRADE_TO_1_1

[2]  Upgrading Projects from 1.1 to 1.2

http://trac.symfony-project.org/browser/branches/1.2/UPGRADE_TO_1_2

some usefule symfony plugins :)