SlideShare a Scribd company logo
1 of 8
Hello Popescu2
• composer create-project symfony/website-skeleton symfony3
• cd symfony3
• php bin/console make:controller
>FormaController
• composer php/bin server:start
• http://localhost:8000/forma
Vederea base.html.twig
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock
%}</title>
{% block stylesheets %}{% endblock %}
</head>
<body bgcolor="aquamarine">
{% block body %}{% endblock %}
{% block javascripts %}{% endblock %}
</body>
</html>
Vederea forma/index.html.twig
{% extends 'base.html.twig' %}
{% block title %}Hello!{% endblock %}
{% block body %}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
{% endblock %}
Vederea forma/result.html.twig
{% extends 'base.html.twig' %}
{% block title %}Hello!{% endblock %}
{% block body %}
{{msg|raw}}
{% endblock %}
Controller-ul FormaController
<?php
namespace AppController;
use SymfonyComponentRoutingAnnotationRoute;
use
SymfonyBundleFrameworkBundleControllerController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentForm;
use
SymfonyComponentFormExtensionCoreTypeTextType;
use
SymfonyComponentFormExtensionCoreTypeSubmitType
class FormaController extends Controller
{
/**
* @Route("/forma", name="forma")
*/
public function index(Request $request)
{
$form=$this->createFormBuilder()
->setAction($this->generateUrl('hello'))//se utilizeaza numele
controlului adnotat!!!
->setMethod('POST')
->add('nume', TextType::class, array('attr'=>array('size'=>'30')))
->add('submit', SubmitType::class)
->getForm();
$form->handleRequest($request);
return $this->render('forma/index.html.twig',array('form'=>$form-
>createView()));
}
/**
* @Route("/hello", name="hello")
*/
public function hello(Request $request)
{
$var = $request->request->all();
$data['msg']="Hello <b>".$var['form']['nume']."</b>!";
return $this->render('forma/result.html.twig', $data);
}
}

More Related Content

What's hot

Gutenberg Blocks Development for Programmers with no time
Gutenberg Blocks Development for Programmers with no timeGutenberg Blocks Development for Programmers with no time
Gutenberg Blocks Development for Programmers with no timeMauricio Gelves
 
Joomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesJoomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesAndy Wallace
 
Joomla Day UK 2009 Menus Presentation
Joomla Day UK 2009 Menus PresentationJoomla Day UK 2009 Menus Presentation
Joomla Day UK 2009 Menus PresentationChris Davenport
 
Joomla! Day UK 2009 Menus Presentation
Joomla! Day UK 2009 Menus PresentationJoomla! Day UK 2009 Menus Presentation
Joomla! Day UK 2009 Menus PresentationAndy Wallace
 
How to Create simple One Page site
How to Create simple One Page siteHow to Create simple One Page site
How to Create simple One Page siteMoneer kamal
 
Class 3 create an absolute layout with css abs position (aptana)
Class 3  create an absolute layout with css abs position (aptana)Class 3  create an absolute layout with css abs position (aptana)
Class 3 create an absolute layout with css abs position (aptana)Erin M. Kidwell
 
ใบความรู้ที่ 2.15 ฟอร์ม-2
ใบความรู้ที่ 2.15 ฟอร์ม-2ใบความรู้ที่ 2.15 ฟอร์ม-2
ใบความรู้ที่ 2.15 ฟอร์ม-2Samorn Tara
 
Tour of Ecto March 2017 Dave Lucia
Tour of Ecto March 2017 Dave LuciaTour of Ecto March 2017 Dave Lucia
Tour of Ecto March 2017 Dave LuciaDavid Lucia
 
引き出しとしてのDjango - SoozyCon7
引き出しとしてのDjango - SoozyCon7引き出しとしてのDjango - SoozyCon7
引き出しとしてのDjango - SoozyCon7makoto tsuyuki
 
Functional testing with capybara
Functional testing with capybaraFunctional testing with capybara
Functional testing with capybarakoffeinfrei
 
A Two-step Dance with Django and Jinja2 Templates
A Two-step Dance with Django and Jinja2 TemplatesA Two-step Dance with Django and Jinja2 Templates
A Two-step Dance with Django and Jinja2 Templatessmirolo
 
web design and jQuery introduction in persian
web design and jQuery introduction in persianweb design and jQuery introduction in persian
web design and jQuery introduction in persianAhmad Badpey
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识ppanyong
 
Joomla! Frappe - Κατασκευή εφαρμογών για το Joomla! χωρίς να τραβάτε τα μαλιά...
Joomla! Frappe - Κατασκευή εφαρμογών για το Joomla! χωρίς να τραβάτε τα μαλιά...Joomla! Frappe - Κατασκευή εφαρμογών για το Joomla! χωρίς να τραβάτε τα μαλιά...
Joomla! Frappe - Κατασκευή εφαρμογών για το Joomla! χωρίς να τραβάτε τα μαλιά...Nicholas Dionysopoulos
 
Class 4 handout two column layout w mobile web design
Class 4 handout two column layout w mobile web designClass 4 handout two column layout w mobile web design
Class 4 handout two column layout w mobile web designErin M. Kidwell
 

What's hot (20)

Gutenberg Blocks Development for Programmers with no time
Gutenberg Blocks Development for Programmers with no timeGutenberg Blocks Development for Programmers with no time
Gutenberg Blocks Development for Programmers with no time
 
Imageslider
ImagesliderImageslider
Imageslider
 
aman's code
aman's codeaman's code
aman's code
 
Joomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic TemplatesJoomla! Day UK 2009 Basic Templates
Joomla! Day UK 2009 Basic Templates
 
Joomla Day UK 2009 Menus Presentation
Joomla Day UK 2009 Menus PresentationJoomla Day UK 2009 Menus Presentation
Joomla Day UK 2009 Menus Presentation
 
Hyperlink
HyperlinkHyperlink
Hyperlink
 
Joomla! Day UK 2009 Menus Presentation
Joomla! Day UK 2009 Menus PresentationJoomla! Day UK 2009 Menus Presentation
Joomla! Day UK 2009 Menus Presentation
 
How to Create simple One Page site
How to Create simple One Page siteHow to Create simple One Page site
How to Create simple One Page site
 
Capybara
CapybaraCapybara
Capybara
 
Class 3 create an absolute layout with css abs position (aptana)
Class 3  create an absolute layout with css abs position (aptana)Class 3  create an absolute layout with css abs position (aptana)
Class 3 create an absolute layout with css abs position (aptana)
 
ใบความรู้ที่ 2.15 ฟอร์ม-2
ใบความรู้ที่ 2.15 ฟอร์ม-2ใบความรู้ที่ 2.15 ฟอร์ม-2
ใบความรู้ที่ 2.15 ฟอร์ม-2
 
Tour of Ecto March 2017 Dave Lucia
Tour of Ecto March 2017 Dave LuciaTour of Ecto March 2017 Dave Lucia
Tour of Ecto March 2017 Dave Lucia
 
引き出しとしてのDjango - SoozyCon7
引き出しとしてのDjango - SoozyCon7引き出しとしてのDjango - SoozyCon7
引き出しとしてのDjango - SoozyCon7
 
styleSample
styleSamplestyleSample
styleSample
 
Functional testing with capybara
Functional testing with capybaraFunctional testing with capybara
Functional testing with capybara
 
A Two-step Dance with Django and Jinja2 Templates
A Two-step Dance with Django and Jinja2 TemplatesA Two-step Dance with Django and Jinja2 Templates
A Two-step Dance with Django and Jinja2 Templates
 
web design and jQuery introduction in persian
web design and jQuery introduction in persianweb design and jQuery introduction in persian
web design and jQuery introduction in persian
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
 
Joomla! Frappe - Κατασκευή εφαρμογών για το Joomla! χωρίς να τραβάτε τα μαλιά...
Joomla! Frappe - Κατασκευή εφαρμογών για το Joomla! χωρίς να τραβάτε τα μαλιά...Joomla! Frappe - Κατασκευή εφαρμογών για το Joomla! χωρίς να τραβάτε τα μαλιά...
Joomla! Frappe - Κατασκευή εφαρμογών για το Joomla! χωρίς να τραβάτε τα μαλιά...
 
Class 4 handout two column layout w mobile web design
Class 4 handout two column layout w mobile web designClass 4 handout two column layout w mobile web design
Class 4 handout two column layout w mobile web design
 

Similar to 5.hello popescu2

Simple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsSimple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsDavid Lucia
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsAlex Eftimie
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Hugo Hamon
 
JavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptxJavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptxVivekBaghel30
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Lar21
 
Django Girls Mbale [victor's sessions]
Django Girls Mbale [victor's sessions]Django Girls Mbale [victor's sessions]
Django Girls Mbale [victor's sessions]Victor Miclovich
 
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersJames Gray
 
1 Introduction to PHP Overview This lab walks y.docx
1  Introduction to PHP Overview This lab walks y.docx1  Introduction to PHP Overview This lab walks y.docx
1 Introduction to PHP Overview This lab walks y.docxhoney725342
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 

Similar to 5.hello popescu2 (20)

11. move in Symfony 4
11. move in Symfony 411. move in Symfony 4
11. move in Symfony 4
 
6.copy text
6.copy text6.copy text
6.copy text
 
13. view data
13. view data13. view data
13. view data
 
Simple Markdown with Ecto and Protocols
Simple Markdown with Ecto and ProtocolsSimple Markdown with Ecto and Protocols
Simple Markdown with Ecto and Protocols
 
PhpBB meets Symfony2
PhpBB meets Symfony2PhpBB meets Symfony2
PhpBB meets Symfony2
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Polymer 1.0
Polymer 1.0Polymer 1.0
Polymer 1.0
 
18. images in symfony 4
18. images in symfony 418. images in symfony 4
18. images in symfony 4
 
Flask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshopsFlask intro - ROSEdu web workshops
Flask intro - ROSEdu web workshops
 
Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2Build powerfull and smart web applications with Symfony2
Build powerfull and smart web applications with Symfony2
 
JavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptxJavaScriptL18 [Autosaved].pptx
JavaScriptL18 [Autosaved].pptx
 
Print this
Print thisPrint this
Print this
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
 
Django Girls Mbale [victor's sessions]
Django Girls Mbale [victor's sessions]Django Girls Mbale [victor's sessions]
Django Girls Mbale [victor's sessions]
 
Django crush course
Django crush course Django crush course
Django crush course
 
Stole16
Stole16Stole16
Stole16
 
DRYing Up Rails Views and Controllers
DRYing Up Rails Views and ControllersDRYing Up Rails Views and Controllers
DRYing Up Rails Views and Controllers
 
1 Introduction to PHP Overview This lab walks y.docx
1  Introduction to PHP Overview This lab walks y.docx1  Introduction to PHP Overview This lab walks y.docx
1 Introduction to PHP Overview This lab walks y.docx
 
HTML & CSS 2017
HTML & CSS 2017HTML & CSS 2017
HTML & CSS 2017
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 

More from Razvan Raducanu, PhD (20)

12. edit record
12. edit record12. edit record
12. edit record
 
11. delete record
11. delete record11. delete record
11. delete record
 
10. view one record
10. view one record10. view one record
10. view one record
 
9. add new record
9. add new record9. add new record
9. add new record
 
8. vederea inregistrarilor
8. vederea inregistrarilor8. vederea inregistrarilor
8. vederea inregistrarilor
 
7. copy1
7. copy17. copy1
7. copy1
 
6. hello popescu 2
6. hello popescu 26. hello popescu 2
6. hello popescu 2
 
5. hello popescu
5. hello popescu5. hello popescu
5. hello popescu
 
4. forme in zend framework 3
4. forme in zend framework 34. forme in zend framework 3
4. forme in zend framework 3
 
3. trimiterea datelor la vederi
3. trimiterea datelor la vederi3. trimiterea datelor la vederi
3. trimiterea datelor la vederi
 
2.routing in zend framework 3
2.routing in zend framework 32.routing in zend framework 3
2.routing in zend framework 3
 
1. zend framework intro
1. zend framework intro1. zend framework intro
1. zend framework intro
 
17. delete data
17. delete data17. delete data
17. delete data
 
16. edit data
16. edit data16. edit data
16. edit data
 
15. view single data
15. view single data15. view single data
15. view single data
 
14. add data in symfony4
14. add data in symfony4 14. add data in symfony4
14. add data in symfony4
 
12.doctrine view data
12.doctrine view data12.doctrine view data
12.doctrine view data
 
10. add in Symfony 4
10. add in Symfony 410. add in Symfony 4
10. add in Symfony 4
 
1.symfony 4 intro
1.symfony 4 intro1.symfony 4 intro
1.symfony 4 intro
 
23.simple login with sessions in laravel 5
23.simple login with sessions in laravel 523.simple login with sessions in laravel 5
23.simple login with sessions in laravel 5
 

Recently uploaded

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 

Recently uploaded (20)

Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 

5.hello popescu2

  • 2. • composer create-project symfony/website-skeleton symfony3 • cd symfony3 • php bin/console make:controller >FormaController • composer php/bin server:start • http://localhost:8000/forma
  • 3. Vederea base.html.twig <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>{% block title %}Welcome!{% endblock %}</title> {% block stylesheets %}{% endblock %} </head> <body bgcolor="aquamarine"> {% block body %}{% endblock %} {% block javascripts %}{% endblock %} </body> </html>
  • 4. Vederea forma/index.html.twig {% extends 'base.html.twig' %} {% block title %}Hello!{% endblock %} {% block body %} {{ form_start(form) }} {{ form_widget(form) }} {{ form_end(form) }} {% endblock %}
  • 5. Vederea forma/result.html.twig {% extends 'base.html.twig' %} {% block title %}Hello!{% endblock %} {% block body %} {{msg|raw}} {% endblock %}
  • 6. Controller-ul FormaController <?php namespace AppController; use SymfonyComponentRoutingAnnotationRoute; use SymfonyBundleFrameworkBundleControllerController; use SymfonyComponentHttpFoundationRequest; use SymfonyComponentHttpFoundationResponse; use SymfonyComponentForm; use SymfonyComponentFormExtensionCoreTypeTextType; use SymfonyComponentFormExtensionCoreTypeSubmitType
  • 7. class FormaController extends Controller { /** * @Route("/forma", name="forma") */ public function index(Request $request) { $form=$this->createFormBuilder() ->setAction($this->generateUrl('hello'))//se utilizeaza numele controlului adnotat!!! ->setMethod('POST') ->add('nume', TextType::class, array('attr'=>array('size'=>'30'))) ->add('submit', SubmitType::class) ->getForm(); $form->handleRequest($request); return $this->render('forma/index.html.twig',array('form'=>$form- >createView())); }
  • 8. /** * @Route("/hello", name="hello") */ public function hello(Request $request) { $var = $request->request->all(); $data['msg']="Hello <b>".$var['form']['nume']."</b>!"; return $this->render('forma/result.html.twig', $data); } }