Installing Symfony within Netbeans and Wamp

Chapter 1: Setting symfony in Netbeans 6.9 and Wamp 2.0

The plugin Symfony is integrated in Netbeans 6.9, so, it’s not necessary to download it. Anyway, first of all, download and install:

  • Symfony 1.4 (the package)
  • Netbeans 6.9
  • Wamp server 2.0

Extract the files from the symfony archive into the folder wamp (C:\wamp). Rename the new folder in symfony (for having C:\wamp\symfony).

Setting PHP and Symfony

Open Netbeans and click on Tools>Options. Click on the PHP tab for changing some settings:
– General tab: put the path to php.exe from your wamp (C:\wamp\bin\php\php5.3.0\php.exe)

Options PHP (Netbeans)

– Symfony tab: put the path to symfony (C:\wamp\symfony\data\bin\symfony). If nothing is set in Applications, put this: –escaping-strategy=on –csrf-secret=UniqueSecret

Options Symfony

MySQL Server

Go on the Services Windows (next to Project and Files). If it’s not showing, click on Window>Service. Expand Databases, right-click on MySQL and choose Properties. For the purpose of this test, we will not put a password for accessing the database. BUT GET THE HABIT TO SECURE IT. IT MEANS A GOOD PASSWORD AND ANOTHER USERNAME THAN ROOT.

MySQL Server Properties: Basic

If you have already MySQL Workbench installed, you can click on Admin Properties et to put these paths in the adequate fields:

  • Path to admin tool: it’s the path to what you’ll use to manage your database. So whether it’s phpMyAdmin, MySQL Workbench or others, it’s there you need to put their path.
  • Path to start command: it’s for starting the MySQL service, so check in the bin folder from your Wamp
  • Path to stop command: it’s for closing MySQL, so if it’s mysqladmin, don’t forget to put the following arguments: -u root stop (or instead of root, put the admin username).

MySQL Server Properties: Admin

Normally, everything should be working for your database. Check it by right-clicking on MySQL Server and choose Connect. When you expand this node, you should see the databases stored on it. You can create our database now if you want but I prefer to do it after setting our project.

Time to set a project

It’s time to click on File>New Project. Choose on the left column PHP and on the right one PHP Application.

Etape 1: Nouveau projet

Next, put a name on your project (Games in our case) and change the Sources Folder for your www/games folder. Don’t forget to eventually change the PHP version.

Etape 2: PHP

Be sure to have the configuration on localhost in the next step.

Etape 3: Configuration

Choose Symfony and generate the frontend and backend in the same time.

Etape 4: Framework

Now you’re ready to use the framework… well once we have created our database physically (without tables).

Set the database

So, what to do? Well, you can go back to Services, right-click on MySQL Server, then choose Create and give life to our database. Check with phpMyAdmin by typing localhost in your browser without forgetting to start Wamp server.

Come back to the Projects Window and right-click on Games. Choose Symfony>Run command for accessing to the framework’s commands. Choose configure:database and put as parameters the following line:
« mysql:host=localhost;dbname=games » root

Click on run and check the file databases.yml in games/config if everything is set well:

    class: sfDoctrineDatabase
      dsn: 'mysql:host=localhost;dbname=games'
      username: root
      password: null

Virtual Host

Well, normally now, you can use the framework… but I lied, we have still one thing to do. We need to configure a virtual host on our Wamp. So go in C:\wamp\bin\apache\Apache2.2.11\conf\extra to find the file httpd-vhosts.conf. Edit it with your notepad and put the following code (you can change the number 9093 by 8080):

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

    # This is the configuration for Games

      ServerName project.localhost
      DocumentRoot "C:\wamp\www\games\web"
      DirectoryIndex index.php
      <Directory "C:\wamp\www\games\web">
        AllowOverride All
        Allow from All

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

How to understand that?

– Well, as you can see I’ve already set a name for my virtual host that isn’t 8080. But it’s only because it was taken before (and mainly because the 8080 refused to work when I began to learn Symfony).

– I’ve put a server name like it was recommended but I am not using it. So, you’ll see a lot of localhost:9093 in my URLs.

– The first part of code concerns the folders that the browser can access. So, it will be there you’ll find css, js, images, etc..

– The alias is redirecting to the symfony framework and for default pages

Note that all your symfony project is deployed on the www folder, which is not really a secure way to do. In reality, every folder apart web should be out of the www directory. But I’m still not at the point where I’m feeling at ease with moving these things out and make everything work. Just if you just want to understand the framework like me, let everything like that.

Checking the new project

And now ladies and gentleman, you’re settled for your first symfony project! If you have doubts about the success of what I’ve described: restart Wamp if it was already working and type localhost:9093/frontend_dev.php.

If you want to install XDebug, follow this tutorial.

If you want more:
NetBeans IDE PHP Quick Start Tutorial
Setting Up a PHP Project
Connecting to a MySQL Database
Symfony and Netbeans
Symfony Screencast

  1. Poster un commentaire

Votre commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:


Vous commentez à l’aide de votre compte Déconnexion /  Changer )

Photo Google

Vous commentez à l’aide de votre compte Google. Déconnexion /  Changer )

Image Twitter

Vous commentez à l’aide de votre compte Twitter. Déconnexion /  Changer )

Photo Facebook

Vous commentez à l’aide de votre compte Facebook. Déconnexion /  Changer )

Connexion à %s

%d blogueurs aiment cette page :