Thursday, January 19, 2012

Setting up Windows environment for Symfony2 developing with NetBeans, XAMPP and Git

[UPDATE] This is a series of post in the next one I’ll show you first Symfony2 app and how to make it work with Git. Second post link: Git and first Symfony2 project in NetBeans

Hi,

For a long time there was no sign of me here, but I hope this will change… So what do I do these days, well I want to go in Symfony2 to see how it feels like… Lots of guys were telling me PHP is way faster in development than in Java or .NET Web development so I want to try it out too.

So what do we actually need ?

XAMPP

No problem with that one. Get the latest version, install it but please don’t install MySql and Apache as services.  Than add a system environment variable like XAMPP_HOME for example and than add

;%XAMPP_HOME%\php;%XAMPP_HOME%\mysql\bin\

to Path environment variable. Now you should be able to check your PHP version from command line.

Try it now

XDEBUG based on your own phpinfo

A friend of mine showed me a wonderful site for getting your own DLL that is needed for your exactly configuration.

But first start your Apache server from your XAMPP control panel. Go to http://localhost/xampp/phpinfo.php and go get view source and copy all the HTML. Now go to http://www.xdebug.org/find-binary.php and insert the HTML into the textarea. Click on “Analyze my phpinfo output” button. And there you go you have your own DLL to download. Download it and put it into your php/ext folder

find_xdebug_binaryfind_xdebug_dll

Now go to your php.ini location and add these lines + the line starting with zend_extension

xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
zend_extension = D:\xampp_server\php\ext\php_xdebug-2.1.2-5.3-vc9.dll

Now your machine should be ready for debug.


INSTALL mSYSGIT – GIT FOR Windows

Go and get the latest msysgit from and install it http://code.google.com/p/msysgit/downloads/list

2012-01-19_1144

SYMFONY2 Package

Go to http://symfony.com/download

Download the latest version in a .ZIP package. At the time of writing this it was Symfony Standart 2.0.9.zip

Make a separate folder and put this zip into it (in my case symfony2_php_sources). Also unzip it into another folder. (in my case symfony2_php_sources/Symfony).

IDE

Well we have some options like Eclipse and NetBeans also some support in PHPStorm, but I choose NetBeans 7.1.

There are a number of reasons why I chose it:

  • Out of box support for YAML
  • Support for Symfony2 (plugin)
  • Support for Twig (templating engine in Symfony2) also plugin
  • More user friendly than Eclipse (I guess someone could argue that, but I worked in Eclipse for 1 year).

So let’s starts go to  http://netbeans.org/downloads/

2012-01-19_1035

Add plugin for Symfony2. Go to Tools –> Plugins –> Tab Available Plugins –> click “Reload Catalog” –: in Search box input “symfony2” and press Enter. Now there should be a plugin there, called PHP Symfony2 Framework. Install it and restart NetBeans.

Add plugin for Twig. For now it is available for download from https://github.com/blogsh/Twig-netbeans/downloads as a NBM file. Download the latest file.

And install it in NetBeans. 

Now let’s tweak it a little bit. Go to Tools –> Options –> PHP.

Here we’ll have a little fun go to General tab –> Indicate your php.exe location in XAMPP. Also add in Global include path unpacked Symfony2 sources.

Go to Unit Testing tab and indicate the location of your phpunit.bat

Go to Symfony2 tab and indicate the location of the downloaded Symfony2 zip file.

Here is the cumulative actions screenshot

THAT’S ALL. Now your machine is configured.

Next time I’ll show you how to work with your first Symfony2 project and Git.

If you have any concerns, suggestions, ideas for blog posts please comment here.

8 comments:

  1. Thank you! Saved me hours of searching and failing.

    ReplyDelete
  2. THIS IS THE BEST GUIDE EVER.. this was JUST what I needed. The second guide too. Thanks a million!

    ReplyDelete
  3. At the moment when we are making "fun" in options, there is line: "Go to Symfony2 tab and indicate the location of the downloaded Symfony2 zip file." Really? Am I lost something in this guide, but I didn't find step when we downloading symfony as a .zip file. Only as a NetBeans plugin. Did I lost something?

    ReplyDelete
    Replies
    1. You have the "SYMFONY2 PACKAGE" section, it says
      Go to http://symfony.com/download

      :)

      Delete
  4. Thank you very much for your work :)

    ReplyDelete
  5. I perefer to use free PHP IDE Codelobster
    It has very cute plugin for Symfony autocomlete

    ReplyDelete
  6. Thanks Man! Easy and followable instructions.

    ReplyDelete