Posts Tagged Tutorial

A Newbie Guide for Symfony

Note: This tutorial using Windows Operating System.

Webserver, PHP, and MySQL Instalation

Webserver: Apache HTTPD

For a webserver, try Apache HTTPD (, download the latest version (2.2.x) and install. After the instalation is finished, browse to:


And it say “It works!”, then the apache installation is done, next we will configure the httpd configuration to be able to browse the symfony application.

Database: MySQL

MySQL database can be found here ( For the client you can use MySQL GUI Tools which can be downloaded at the same location. Or, use the web based client such as PHPMyAdmin (


Download PHP at Usually, the PHP Windows binary package come in an archived or an installer packaging. Download the archived package for version 5.2.x and extract to C:\PHP for example.

Now the time to prepare the php.ini, the sample configuration for PHP already included in the archive–php.ini-dist and php.ini-recommended–for this time, I assumed we are using php.ini-dist, just copy this file and rename to php.ini.

We need to adjust several php configuration, so now use your favorite text editor–such as Notepad++–to edit the php.ini:

If necessary, adjust the include path, locate this line (line 476):

; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"

Change to:

; Windows: "\path1;\path2"
include_path = ".;C:\PHP\PEAR"

Adjust the extension directory, locate this line (line 491):

; Directory in which the loadable extensions (modules) reside.
extension_dir = "./"

Change to:

; Directory in which the loadable extensions (modules) reside.
extension_dir = "C:\PHP\ext\"

Enable needed extensions, locate this line (line 604):

; Windows Extensions
; Note that ODBC support is built in, so no dll is needed for it.
; Note that many DLL files are located in the extensions/ (PHP 4) ext/ (PHP 5)
; extension folders as well as the separate PECL DLL download (PHP 5).
; Be sure to appropriately set the extension_dir directive.


You can enable mbstring, mysql, pdo, pdo_mysql and another extensions may be needed for your project such as gd2 by removing the comment (;–semicolon) preceding each line.
Also, you can add the xdebug ( extension and place in C:\PHP\ext\php_xdebug.dll and add the following line after previous configuration:


To make mysql extension working in PHP, copy the supplied libmysql.dll from C:\PHP\libmysql.dll to C:\WINDOWS\system32\.

Open a Command Prompt and type the following command to install the bundled PEAR package:
cd C:\PHP

Accept the default value while installing PEAR, simply press ENTER to accept.
Here are the sample output:

Are you installing a system-wide PEAR or a local copy?
(system|local) [system] :

Below is a suggested file layout for your new PEAR installation.  To
change individual locations, type the number in front of the
directory.  Type 'all' to change all of them or simply press Enter to
accept these locations.

 1. Installation base ($prefix)                   : C:\PHP
 2. Temporary directory for processing            : C:\PHP\tmp
 3. Temporary directory for downloads             : C:\PHP\tmp
 4. Binaries directory                            : C:\PHP
 5. PHP code directory ($php_dir)                 : C:\PHP\pear
 6. Documentation directory                       : C:\PHP\docs
 7. Data directory                                : C:\PHP\data
 8. User-modifiable configuration files directory : C:\PHP\cfg
 9. Public Web Files directory                    : C:\PHP\www
10. Tests directory                               : C:\PHP\tests
11. Name of configuration file                    : C:\WINDOWS\pear.ini
12. Path to CLI php.exe                           : C:\PHP\.

1-12, 'all' or Enter to continue:
Beginning install...
Configuration written to C:\WINDOWS\pear.ini...
Initialized registry...
Preparing to install...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Archive_Tar-1.3.2.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Console_Getopt-1.2.3.tar...

installing phar://go-pear.phar/PEAR/go-pear-tarballs/PEAR-1.7.2.tar...
installing phar://go-pear.phar/PEAR/go-pear-tarballs/Structures_Graph-1.0.2.tar.
pear/PEAR can optionally use package "pear/XML_RPC" (version >= 1.4.0)
install ok: channel://
install ok: channel://
install ok: channel://
install ok: channel://
PEAR: Optional feature webinstaller available (PEAR's web-based installer)
PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer)
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer)

PEAR: To install optional features use "pear install pear/PEAR#featurename"

** WARNING! Old version found at C:\PHP, please remove it or be sure to use the
new c:\php\pear.bat command

The 'pear' command is now at your service at c:\php\pear.bat

** The 'pear' command is not currently in your PATH, so you need to
** use 'c:\php\pear.bat' until you have added
** 'C:\PHP' to your PATH environment variable.

Run it without parameters to see the available actions, try 'pear list'
to see what packages are installed, or 'pear help' for help.

For more information about PEAR, see:

Thanks for using go-pear!

For convenience, a REG file is available under C:\PHP\PEAR_ENV.reg .
This file creates ENV variables for the current user.

Double-click this file to add it to the current user registry.

Press any key to continue . . .

Setup a Project

For a symfony project setup see Integrating Symfony into Eclipse PDT.

Running Symfony

Now its time to prepare Apache to be able to browse symfony application. The configuration file for Apache is located at C:\Program Files\Apache Software Foundation\Apache2.2\conf\httpd.conf. In this point forward, I assumed your project is located at C:\Project\myproject and the symfony library is located at C:\Project\symfony.

Make Apache HTTPD Understands PHP scripts

Locate the Dynamic Shared Object (DSO) Support configuration, and add the following configuration (add only in comment block):

#LoadModule version_module modules/
#LoadModule vhost_alias_module modules/

### BEGIN ADD ###

# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2_2.dll"
AddType application/x-httpd-php .php

# configure the path to php.ini
PHPIniDir "C:/php"

### END ADD ###
<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>

Add index.php as DirectoryIndex, locate:

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.html

Change to:

# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
<IfModule dir_module>
    DirectoryIndex index.php index.html
Configuring Apache Modules

At this time the only needed apache module is mod_rewrite, locate:

#LoadModule rewrite_module modules/

And remove the comment from the line:

LoadModule rewrite_module modules/

If you need another module, enable the corresponding module as you need.

Setup a Virtual Host

To support a virtual host, add the following lines to the end of the configuration file:

### all vhost configurations
Include conf/myconf/*.conf

You’re done with your httpd configuration. Now we can create the virtual host configuration for symfony application–myproject. So create myproject.conf and place it in C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\:

# C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\myproject.conf
<VirtualHost *:80>
    ServerAdmin admin@myproject.localhost
    #ServerName myproject.localhost
    #ServerAlias www.myproject.localhost
    ErrorLog "logs/myproject.localhost-error.log"
    CustomLog "logs/myproject.localhost-access.log" common
    DocumentRoot "C:/Project/myproject/web"
<Directory "C:/Project/myproject/web">
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
<Directory "C:/Project/symfony/data/web/sf">
        AllowOverride All
        Allow from all
    Alias /sf "C:/Project/symfony/data/web/sf"

Add another configuration, for instance PHPMyAdmin. PHPMyAdmin files can be placed in C:\Project\phpmyadmin:

# C:\Program Files\Apache Software Foundation\Apache2.2\conf\myconf\phpmyadmin.conf
<Directory "C:/Project/phpmyadmin">
    AllowOverride All
    Allow from all

Alias /phpmyadmin "C:/Project/phpmyadmin"
Browse your application

Restart the httpd web server, open Command Prompt, type:
net stop Apache2.2
net start Apache2.2

Now open your browser and goto:

, , , ,

Leave a comment

Integrating Symfony into Eclipse PDT

This tutorial is intended to integrate symfony into PHP Delevopment Tool (PDT) as an IDE, so the Code Completion feature can be invoked. Also, we can call the symfony command directly from PDT. This tutorial using Windows XP Operating System, for other OS may have a slight different.


  1. Download the Java Runtime Environment (JRE), the minimum version supported is version 5 of JRE (
  2. Download the Eclipse PDT located at Eclipse PDT package for windows usually packaged as ZIP archieve.
  3. Download the YAML Editor plugin for Eclipse (
  4. If you’re using Subversion, also download Subclipse (
  5. Download the symfony library either by PEAR package or from Subversion repository.


  1. PHP must has already been installed, the symfony CLI need the PHP CLI for its to run. And, the path of PHP CLI has already included into PATH system variable. To do this, right click at the My Computer icon, then select Properties. At the System Properties dialog, activate the Advanced tab, then locate the PATH variable from the System variables list. Ensure if PHP CLI path has already included by choosing the Edit button and add the path (for instance, C:\PHP), separated by semi-colon (;).
  2. Install the Java Runtime Environment.
  3. Extract the PDT package, PDT package come with full path already, so just extract it to C:\. The executable file for PDT loacted at C:\eclipse\eclipse.exe and create a shortcut in desktop for easy the use of PDT.
  4. Install all plugins. For installing just extract the plugins into C:\eclipse\plugins. If you are using PDT 2.0, consider using new plugins path C:\eclipse\dropins\eclipse\plugins.
  5. Prepare the folder for all our project files, C:\Project would be a good starting point.
  6. Extract the symfony package (for PEAR package) or copy (Subversion repository) to C:\Project\symfony.
  7. Now, we can run the PDT and integrate symfony in it. Run the PDT by the shortcut we have just created in step 3. First time, Eclipse PDT will asking the location of workspace to be used, just provide C:\Project as the workspace location, also mark Use this as the default and do not ask again if everytime the Eclipse PDT run, this dialog would not be displayed again.
  8. PDT shows Welcome, choose Workbench to start using the PDT IDE.
  9. By default, the active perspective is Resource, so, change it into PHP. Click the Open Perspective button (1) dan activate PHP (2).
  10. Now, make the symfony library as a PHP project. Symfony library has been already prepared in step 6. Choose File > New > PHP Project. Named it as symfony (1) and then click the Finish button (2).
  11. Create our working project, for instance myproject. Do the previous step, name the project as myproject, click Next > (not the Finish button). At the PHP Include Path configuration, activate Projects tab (1) and click the Add… button (2). At the Required Project Selection dialog, mark the symfony project and choose OK. Finish the project creation by clicking the Finish button. This project is still empty by default.
  12. To integrate symfony CLI into PDT IDE, Choose Run > External Tools > Open External Tools Dialog…. To create a new command, right click at the Program tree and choose New. At the Create, manage, and run configurations, provide this parameters:
    • Name: symfony command (showed as command name).
    • Location: ${workspace_loc:/symfony/data/bin/symfony.bat} (use the Browse workspace… button to choose those location).
    • Working Directory: ${project_loc} (for multiple projects, as alternate for single project can be ${workspace_loc:/myproject}, myproject is a project name).
    • Arguments: ${string_prompt} (will prompt string input dialog, use the Variables button to see the others arguments variables).

  13. Create the others command we’re generally used, for instance cc. Repeat the previous step and provide the same parameters, except, Name fill with symfony clear cache and Arguments fill with cache:clear (symfony 1.1 up) or clear-cache (symfony 1.0). Repeat for all your favorites commands.
  14. To speed up the command access, add those commands into favorites. Choose Run > External Tools > Organize Favorites…. At the Organize External Tools dialog, use the Add… button to add to favorites list. Mark the check to all commands which are favorites. Those commands now will be available through the toolbar (see figure).
  15. Check if the command has been working correctly. Try to run the command by accesing the toolbar. But, make sure you have select a project first (click at myproject first). At the Variable input dialog leave it blank and choose OK. The command output can be viewed within Console window.
  16. The previous project we have just created first is empty by default (step 11), so, use the symfony command to make it as symfony project. Run the symfony command and provide generate:project myproject (init-poject myproject for symfony 1.0) and examine the result in the Console window.
  17. The last step, is to make PDT compliant with symfony. Activate the Preferences dialog by accessing Window > Preferences…. The settings which must be changed are:
    • General > Workspace > Text file encoding > Other: utf-8.
    • PHP > Editor > Code Folding > Enable folding: off.
    • PHP > Formatter > Formatting > Tab policy: Spaces.
    • PHP > Formatter > Formatting > Indentation size: 2.
  18. You’re ready using PDT for your project.

, , ,


Mengintegrasikan Symfony dengan Eclipse PDT

Tutorial ini bertujuan untuk mengintegrasikan symfony ke PHP Delevopment Tool (PDT) sebagai IDE sehingga fasilitas Code Completion untuk symfony dapat berjalan dalam PDT. Juga, kita dapat menjalankan perintah-perintah symfony langsung dari PDT.

Dalam tutorial ini menggunakan OS Windows XP, untuk OS lain mungkin ada sedikit perbedaan.


  1. Download Java Runtime Environment (JRE), versi minimal yang didukung adalah JRE versi 5 (
  2. Download Eclipse PDT yang terdapat di Paket Eclipse PDT untuk windows biasanya dalam bentuk arsip ZIP.
  3. Download plugin YAML Editor untuk eclipse (
  4. Jika anda menggunakan Subversion download juga Subclipse (
  5. Download librari symfony baik yang berupa paket PEAR atau dari repository SVN.


  1. PHP sudah harus terinstall, symfony CLI membutuhkan PHP CLI untuk bisa berjalan. Dan path PHP CLI tersebut juga harus disertakan dalam variabel PATH. Untuk melakukannya, klik kanan ikon My Computer, pilih Properties. Pada Dialog System Properties klik pada tab Advanced, kemudian cari variabel Path dari daftar System variables. Pastikan path PHP CLI sudah ada dengan memilih tombol Edit dan tambahkan path (contoh C:\PHP) dipisahkan dengan titik-koma (;).
  2. Install Java Runtime Environment.
  3. Ekstrak paket PDT, biasanya paket PDT sudah berisi path penuh sehingga cukup ekstrak ke C:\ sebagai contoh. File eksekusi PDT adalah C:\eclipse\eclipse.exe dan buatkan shortcut di desktop untuk memudahkan memanggil PDT.
  4. Install semua plugin. Untuk menginstall plugin cukup ekstrak plugin tersebut ke C:\eclipse\plugins. Jika anda menggunakan PDT 2.0, sebaiknya gunakan lokasi plugin baru di C:\eclipse\dropins\eclipse\plugins
  5. Siapkan folder di mana file-file proyek akan dibuat, C:\Project akan mejadi awal yang baik.
  6. Ekstrak paket symfony (Paket PEAR) atau copy-kan (versi SVN) ke C:\Project\symfony.
  7. Sekarang waktunya menjalankan PDT dan mengintegrasikan symfony ke dalamnya. Jalankan PDT lewat shortcut yang kita buat pada langkah 3. Ketika pertama kali dijalankan, Eclipse PDT akan menanyakan lokasi workspace yang akan digunakan, cukup gunakan C:\Project sebagai lokasi workspace, beri centang pada Use this as the default and do not ask again jika setiap kali menjalankan Eclipse PDT dialog ini tidak ingin ditampilkan.
  8. PDT kemudian menampilkan dialog Welcome, pilih pada Workbench untuk memulai menggunakan IDE PDT.
  9. Secara default, perspektif yang aktif adalah Resource, untuk itu ubah perspektif menjadi PHP. Klik pada tombol Open Perspective (1) dan pilih PHP (2).
  10. Sekarang, masukkan librari symfony sebagai sebuah proyek. Librari symfony telah kita persiapkan pada langkah 6. Pilih File > New > PHP Project. Beri nama proyek sebagai symfony (1) dan kemudian klik pada Finish (2).
  11. Buat proyek sesungguhnya di mana kita akan bekerja, misalnya myproject. Lakukan seperti langkah sebelumya, beri nama proyek sebagai myproject, kemudian klik Next > (jangan Finish). Pada konfigurasi PHP Include Path, aktifkan tab Projects (1) dan klik tombol Add…(2). Pada dialog Required Project Selection, tandai proyek symfony dan pilih OK. Akhiri pembuatan proyek dengan meng-klik pada tombol Finish. Proyek yang kita buat di sini masih berupa proyek kosong.
  12. Untuk mengintegrasikan symfony CLI ke dalam IDE PDT, Pilih Run > External Tools > Open External Tools Dialog…. Untuk membuat perintah baru, klik kanan pada tree Program dan pilih New. Pada konfigurasi Create, manage, and run configurations isikan parameter-parameter berikut:
    • Name: symfony command (akan tampil sebagai nama perintah).
    • Location: ${workspace_loc:/symfony/data/bin/symfony.bat} (gunakan tombol Browse workspace… untuk memilih lokasi tersebut).
    • Working Directory: ${project_loc} (untuk multi project, alternatif untuk single project bisa menggunakan ${workspace_loc:/myproject}, myproject adalah nama proyek).
    • Arguments: ${string_prompt} (akan menampilkan dialog input string, gunakan tombol Variables untuk alternatif variabel argumen lainnya).

  13. Buat perintah-perintah lain yang sering kita gunakan misalnya, cc. Ulangi langkah di atas dan gunakan paremeter-parameter tersebut kecuali untuk Name isi dengan symfony clear cache dan Arguments isikan dengan cache:clear (symfony 1.1 ke atas) atau clear-cache (symfony 1.0). Ulangi untuk semua perintah-perintah favorit anda.
  14. Untuk mempercepat eksekusi perintah, tambahkan perintah-perintah tadi sebagai favorit. Pilih Run > External Tools > Organize Favorites…. Pada dialog Organize External Tools, gunakan tombol Add… untuk menambahkan daftar favorit. Beri tanda centang pada semua perintah yang akan dimasukkan ke daftar favorit. Shortcut perintah favorit dapat diakses melalui toolbar (lihat gambar).
  15. Periksa apakah perintah-perintah yang kita buat sudah bekerja. Coba jalankan perintah symfony command melalui shortcut toolbar. Tetapi sebelumnya, sebuah proyek harus sudah terseleksi lebih dahulu (pilih pada myproject telebih dahulu). Pada dialog Variable input biarkan kosong dan pilih OK. Output perintah yang kita jalankan dapat dilihat dari jendela Console.
  16. Proyek yang kita buat sebelumnya masih berupa proyek kosong (langkah 11), untuk itu gunakan symfony command untuk membuatnya sebagai proyek symfony. Masukkan generate:project myproject (init-poject myproject untuk symfony 1.0) dan lihat hasilnya dari jendela Console.
  17. Langkah terakhir, yaitu membuat PDT agar komplian dengan symfony. Aktifkan dialog Preferences dengan memilih Window > Preferences…. Setting-setting yang perlu kita ubah antara lain:
    • General > Workspace > Text file encoding > Other: utf-8.
    • PHP > Editor > Code Folding > Enable folding: off.
    • PHP > Formatter > Formatting > Tab policy: Spaces.
    • PHP > Formatter > Formatting > Indentation size: 2.
  18. Sekarang anda siap bekerja menggunakan PDT.

, , ,