Technical blog of COil: Symfony, PHP, PEAR & webdev

Strangebuzz...?

» Collapse all «

Tag - generator

     

Thursday 3 April 2008

symfony 1.0 tutorial : Extending the admin generator

[En] Tutorial content:

  • Creating a plugin with a custom admin generator theme
  • Extending the sfActions class
  • Extending the sfPropelAdminGenerator class


Here is little contribution for the symfony code sprint, a symfony tutorial about the admin generator. :) Do you know about it ? I think it's one of my favourite symfony tool, i have developed several applications with symfony and for 75% of them i have made a custom admin generator theme. And as said in the symfony documentation, the admin generator is very very very powerful. ;)
In this tutorial we will see a concrete example on how to extend it to provide a useful new feature. Witch feature ? Well it was one of the things a customer asked me, "I want to be able to delete several rows at a time with check boxes" ... Ahhhhh indeed, it's not a native feature of the admin generator. So.... let's do it... :)

::: Pre-requisite :::


Well i will not explain here how to install symfony as there are lots of tutorials about this on the symfony website and in the wiki. So i will assume you have a clean symfony installation so you can type the symfony command in cli. I used the 1.0.13 version for this tutorial.

::: Creating and setting a new project :::


:: Creating the new project ::


First we will create the new project that we will call tutorial, create a new folder tutorial and launch the init-project task into it.

symfony init-project tutorial

Now let's create the backend application:

symfony init-app backend

As it is always better to have a submain for our application add the following in you apache httpd.conf file and change it with your own path

## COil symfony tutorial n°1 : Extending the admin generator ##

<VirtualHost *:80>
  ServerName dev.tutorial.com
  DocumentRoot "C:\wamp\www\tutorial\web"
  DirectoryIndex index.php
  Alias /sf "c:\wamp\bin\php\php5.2.5\PEAR\data\symfony\web\sf"
  
  <Directory "C:\wamp\www\tutorial\web">
    AllowOverride All
  </Directory>
</VirtualHost>

Add the sub-domain in you hosts file:

127.0.0.1 dev.tutorial.com

Ok, at this point we should have our "Project created!" page. So Let's try to browse http://dev.tutorial.com/backend_dev.php

tuto1-1


:: The database ::


Create a local database, let's call it tutorial again. (same as the project name)
Modify the database settings in the config/database.yml and config/propel.ini file, your database.yml file should look like this:

all:
  propel:
    class:          sfPropelDatabase
    param:
      dsn:          mysql://root@localhost/tutorial


Now we need a schema, let's take the one of Askeet


Ok now let's try to build the database:

symfony.bat propel-build-all-load backend

Oops, it seems there are some errors. :) As we are quite lazy just delete the password columns and the QuestionTag section of the /datas/fixtures/test_data.yml file.
Let's try again to run the last command. If your are successful you should now have some tables and data in your tutorial database. If not, you probably missed something. ;) At this point we have a valid application with a database, some tables and fixtures. Settings are ok, so can go to the next step.

...

Continue reading...

Sunday 14 January 2007

Multi-sort dans l'admin generator de Symfony

[En] Welcome on my new blog that will mainly talk about PHP, the Symfony framework and web2.0.

[Es] Bienvenido en mi nuevo blog, principalmente hablando sobre PHP, Symfony framework y web2.0.

[Fr] Voilà je me suis décidé à ouvrir mon Blog, non pour raconter ma vie... quoi que ;) ... Mais pour parler essentiellement de programmation, notamment PHP et le framework Symfony dont je suis très friand ces derniers temps. ;) J'ai choisi DotClear pour sa réputation, sa facilité d'utilisation, les thèmes disponibles et les plugins. Je ne suis vraiment pas déçu pour l'instant. C'est propre et clair. J'ai du installer un plugin intégrant Geshi pour la coloration syntaxique PHP.


Présentation

Une petite présentation (vite-fait hein...) je suis COil (devinez-mon prénom ?), j'ai 28 ans... Et je me suis re-mis (**sérieusement**) au PHP et aux technos web depuis 6 mois apres une longue mission à Paris, ça fait du bien. La conception technique de sites web, le php et le webmastering étant vraiment les disciplines que je préfère.


J'espère que vous pourrez trouver ici quelques informations intéressantes à l'occasion. (pas toujours quand même, faut pas pousser...) :o