Note: This article is a translation of a Spanish article written by Diego Silva


Symfony on Windows in NetBeans 6.8

Symfony is a framework for PHP that allows you to develop web applications based on MVC. It helps enormously in building complex web applications in PHP. While symfony was designed to work from the command line, NetBeans 6.8 support for symfony lets you use it in the NetBeans graphic user interface.

Installing the Symfony plug-in

Installation is fairly simple. It can be downloaded from the Update Center (Tools> Add-ons). We have installed the plugin for PHP. If you do not have it installed, this is a good time to do so.


... If you install the PHP plugin, the IDE will prompt you to install the JavaScript Debugger


Let the IDE install the plug-ins, and when it is finished, the IDE will ask if you want to restart the IDE. And that'll do: restart the IDE.

Installing Symfony

In the previous section we installed only NetBeans IDE's support for symfony. We also need to install the actual symfony framework. For this we must do the following

  1. Download symfony from here:
  2. Although symfony has its own installation instructions, here we follow our own course. Extract the Zip file in the root of C:\ so that you have created a folder called

Usually, that's all you need to do to install symfony.

If you have already installed symfony before setting up symfony support in NetBeans IDE, it does not matter. The important thing is to remember where you are.

Configuring the Symfony Plug-in

Now, in NetBeans we go to Tools> Options and select "PHP". Then open the "symfony" tab. What we do here is to select the main script for symfony.


Note that the file has no extension. Actually (if opened from a text editor) it is a PHP file, but it doesn't have the .php extension.

Creating a Project

Now create a new PHP project using symfony. Press Shift + Ctrl + N (File> New Project)


Click Next. We create the project name. For our example it will be "MiApp."


We leave the other default options. Click Next

Set the path to be displayed in the browser when you run the application.

Click Next.

Now, select the "Symfony" framework.


Note that is calling a special key, for security purposes to prevent attacks CSRF token in forms. For purposes of this tutorial, we will use the same key proposal UniqueSecret.

Click Finish.

The IDE now creates our project.

Preparing the project

Configuring Apache

This application runs on the Apache Web Server, which must be installed. What we recommend is to run the symfony development application on another host. This host will be local and virtual, so that it runs under a different name on another host and port number. In our case it running on port 9090.

On the left side of our project, we open the config / vhost.sample which has a code like this:

    # Be sure to only have this line once in your configuration

    # This is the configuration for MiApp

      ServerName MiApp.localhost
      DocumentRoot "D:\home\DSILVA\Mis documentos\NetBeansProjects\MiApp\web"
      DirectoryIndex index.php
      <Directory "D:\home\DSILVA\Mis documentos\NetBeansProjects\MiApp\web">
        AllowOverride All
        Allow from All

      Alias /sf "C:\symfony-1.2.9\data\web\sf"
      <Directory "C:\symfony-1.2.9\data\web\sf">
        AllowOverride All
        Allow from All

Well, what we do first is to edit this file to run the symfony application on port 9090, as follows:

    # Be sure to only have this line once in your configuration

    # This is the configuration for MiApp

      ServerName MiApp.localhost
      DocumentRoot "D:\home\DSILVA\Mis documentos\NetBeansProjects\MiApp\web"
      DirectoryIndex index.php
      <Directory "D:\home\DSILVA\Mis documentos\NetBeansProjects\MiApp\web">
        AllowOverride All
        Allow from All

      Alias /sf "C:\symfony-1.2.9\data\web\sf"
      <Directory "C:\symfony-1.2.9\data\web\sf">
        AllowOverride All
        Allow from All

The routes of the project folder have already been established by symfony.


  1. Copy this content,
  2. Open up the httpd.conf file located in the $ APACHE_HOME \ conf,
  3. Paste the content
  4. Save your changes
  5. And restart the Apache service.
To see if you have Apache configured correctly, open up the browser on
, or run the project with the F6 key.


Configuring the database

Now we have to create the database. From the MySQL console (can be useful on the command line, or the more sophisticated uses) execute (as root) the following:

create database tienda_virtual; #crea la base de datos
grant all on tienda_virtual.* to tienda_virtual@localhost identified by "tienda_virtual"; #crea un usuario con acceso a esa base de datos

Run from NetBeans.

I recommend not to use the root user to access a database from the application. Therefore I recommend creating a user for every database that is being created. It is for security purposes.

Then we set the configuration of our application with the database. To do this, right click on the icon of the symfony project and select Symfony > Run command ...


This opens the symfony Run Command dialog. Type "config" into the Filter field and the IDE displays the commands associated with configure. Select configure:database from the list and write as arguments "mysql: host = localhost, dbname = store" shop store


Then click "Run".

We can see that it has updated the file config/databases.yml.

Creating tables

The tables can be created from the config/schema.yml file. Yml is a standard serialization and friendly programming languages.

We will create two tables: product_type and product. To do this, edit config/schema.yml with the following:

    type_id: ~
    type_name: {type: varchar(255)}
    product_id: ~
    type_id: {type: integer,foreignTable: product_type, foreignReference: type_id,required: true}
    Product Name: {type: varchar(255)}
    stock: {type: integer}
    Price: {type: double(10,5)}

Note the spaces between each statement, type and value.

Now you can use symfony inside NetBeans IDE to create the tables. To do this, from the Run Command dialog, find and run the


This will create the schema for our application and also the tables in our database


Note: If you already have created a database, do not edit
config/schema.yml</tt> and run the command <tt>{symfony propel:build-schema
And to end with the database, we must create the data model, which is a php class mapping between the tables of your database. To do this run the command

After that, we see the result in the lib folder


Running the application

The application is not quite finished. Missing styles, colors. But you can see something. Before that, we must build the application. To do this run the command
. This builds everything about the scheme until the forms.


Then run
with the parameters as shown in the image.


And so we have the table "product_type." Click here to see





Since the purpose of this tutorial was not to be a course of symfony, I suggest reading the useful manual
, which shows you over 24 days (for one hour each day) how to make a functional project with symfony.
Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo