Creare la cartella di progetto
1. Create the folder c:\wamp64\www\jobeet
Creare la struttura di cartelle
2. Inside \jobeet folder run the command:
cmd.exe -> c:\wamp64\www\jobeet\symfony generate:project jobeet –orm=Propel
Tris create the basic folders
Creare la app frontend
3. Copy C:\wamp64\bin\php\symfony.bat to c:\wamp64\www\jobeet\
4. cmd.exe -> c:\wamp64\www\jobeet\symfony generate:app frontend
This create the base content of \apps
Creare il contenuto
5. cmd.exe -> c:\wamp64\www\jobeet\symfony generate:module frontend contenuto
Crea il contenuto per \modules
6. Per ogni nuovo modulo, Symfony crea una azione index predefinita, puntiamo il browser a:
http://localhost/jobeet/web/contenuto/index
7. Apriamo il file apps/frontend/modules/contenuto/actions/actions.class.php e scriviamo
1 2 3 4 5 6 7 8 9 10 11 12 | <?php class contenutoActions extends sfActions // estende la classe Symfony { public function executeAboutme() // crea l'indirizzo - contenuto/aboutme { } // END function public function executeContact() // crea l'indirizzo - contenuto/contact { } // END function } // END class |
8. Creiamo apps/frontend/modules/contenuto/templates/aboutmeSuccess.php
1 | <p>About me: I am <strong>Andrea</strong></p> |
9. Creiamo apps/frontend/modules/contenuto/templates/contactSuccess.php
1 | <p>Contact: My telephone number is 0123456789</p> |
10. Puntiamo il browser a:
– http://localhost/jobeet/web/contenuto/aboutme
– http://localhost/jobeet/web/contenuto/contact
Come funziona?
I template dovranno essere nominati seguendo la regola:
aboutmeSuccess.php -> nomelink + Success
I metodi seguiranno la regola:
executeContact() -> execute + (Maiuscola)nomelink
Passare i dati al Template
1. action.class.php
1 2 3 4 5 6 7 8 9 10 11 12 | <?php class contenutoActions extends sfActions // estende la classe Symfony { public function executeRandom() // crea l'indirizzo - contenuto/random { $number = mt_rand(0, 100); // this is plain PHP // invia nella variabile del template numerocasuale in valore $number $this ->numerocasuale = $number ; } // END function } // END class |
2. randomSuccess.php
1 | <p>The random number is <strong><?php echo $numerocasuale ?></strong></p> |
3. Puntare il browser a: http://localhost/jobeet/web/contenuto/random
Abbiamo due tipo di sintassi per assegnare le variabili da passare ai template:
1 2 3 | // Impostare le variabili dell'azione per passare informazioni al template $this ->pippo = 'pluto' ; // Versione breve $this ->setVar( 'pippo' , 'pluto' ); // Versione estesa |
Reference:
http://symfony.com/legacy/doc/gentle-introduction/1_4/it/04-The-Basics-of-Page-Creation