SlideShare uma empresa Scribd logo
1 de 14
Images in Symfony 4
• composer create-project symfony/website-skeleton symfony11
• cd symfony11
Install doctrine:
• composer require doctrine maker
In .env modificati linia:
DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_
name
astfel:
DATABASE_URL=mysql://root@127.0.0.1:3306/images
Porniti serverul MySQL in XAMPP.
Pentru a crea db flowers, scrieti in fereastra consola:
• php bin/console doctrine:database:create
Pentru a crea o “entitate”(MODELUL!) care va gestiona datele unei tabele (care
urmeaza a fi creata) vom scrie:
php bin/console make:entity Image
Fiecare proprietate a clasei Image poate fi asociata
cu un camp al tabelei image.
Aceasta clasa are definite cateva proprietati private
si metodele publice get si set pentru gestionarea
acestora.
Dorim ca tabela image sa aiba campurile:
- id(int, primary key, autoincrement),
– nume(varchar(100))
– poza(varchar(100))
Modificam /src/Flower/Entity.php astfel:
/src/Flower/Entity.php
<?php
namespace AppEntity;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity(repositoryClass="AppRepositoryFlowerRepository")
*/
class Flower
{
/**
* @ORMId()
* @ORMGeneratedValue()
* @ORMColumn(type="integer")
*/
private $id;
/**
* @ORMColumn(type="string", length=100)
*/
private $nume;
/**
* @ORMColumn(type="string", length=100)
*/
private $culoare;
public function getId()
{
return $this->id;
}
public function getNume()
{
return $this->nume;
}
public function getPoza()
{
return $this->poza;
}
public function setId($id)
{
return $this->id=$id;
}
public function setNume($nume)
{
return $this->nume=$nume;
}
public function setPoza($poza)
{
return $this->poza=$poza;
}
}
• Pentru a genera tabela image, va trebui sa
generam mai intati fisierul de migrari:
• php bin/console doctrine:migrations:diff
• Pentru a crea efectiv tabela, scriem:
php bin/console doctrine:migrations:migrate
• php bin/console make:controller
>DefaultController
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 default/index.html.twig
{% extends 'base.html.twig' %}
{% block body %}
<table>
<tr>
<th>Nume</th>
<th>Poza</th>
<th colspan="3">Actions</th>
</tr>
{% for key in images %}
<tr>
<td>{{ key.nume }}</td>
<td><img src="/images/{{ key.poza }}" width="100" height="100"></td>
<td><a href="{{ app.request.baseUrl() }}/show/{{key.id}}">View</a>
<a href="{{ app.request.baseUrl() }}/edit/{{key.id}}">Edit</a>
<a href="{{ app.request.baseUrl() }}/delete/{{key.id}}" onclick="return
confirm('Are you sure you want to delete this item?');">Delete</a>
</td>
</tr>
{% endfor %}
</table>
<a href="{{ app.request.baseUrl() }}/add">Insert a record</a>
{% endblock %}
Controller-ul DefaultController
<?php
namespace AppController;
use SymfonyComponentRoutingAnnotationRoute;
use SymfonyBundleFrameworkBundleControllerController;
use AppEntityImage;
class DefaultController extends Controller
{
/**
* @Route("/", name="default")
*/
public function index()
{
$images = $this->getDoctrine()-> getRepository(Image::class)->findAll();
// replace this example code with whatever you need
return $this->render('default/index.html.twig', array('images'=>$images));
}
}
• In tabela image adaugam:
• In /public cream directorul /images, in care
salvam pozele kali.jpg, lemon.jpg, uaic.jpg,
orange.jpg.

Mais conteúdo relacionado

Mais procurados

Apostrophe
ApostropheApostrophe
Apostrophetompunk
 
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapАндрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapDrupalSPB
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentTammy Hart
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in phpherat university
 
Functional testing with capybara
Functional testing with capybaraFunctional testing with capybara
Functional testing with capybarakoffeinfrei
 
Image Manipulation in WordPress 3.5 - WordCamp Phoenix 2013
Image Manipulation in WordPress 3.5 - WordCamp Phoenix 2013Image Manipulation in WordPress 3.5 - WordCamp Phoenix 2013
Image Manipulation in WordPress 3.5 - WordCamp Phoenix 2013GetSource
 
Make your own wp cli command in 10min
Make your own wp cli command in 10minMake your own wp cli command in 10min
Make your own wp cli command in 10minIvelina Dimova
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress themeHardeep Asrani
 
Introduction to ZendX jQuery
Introduction to ZendX jQueryIntroduction to ZendX jQuery
Introduction to ZendX jQuerydennisdc
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5성일 한
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricksambiescent
 
15.exemplu complet eloquent view add-edit-delete-search
15.exemplu complet eloquent view add-edit-delete-search15.exemplu complet eloquent view add-edit-delete-search
15.exemplu complet eloquent view add-edit-delete-searchRazvan Raducanu, PhD
 
Build a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ TelerikBuild a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ TelerikMario Peshev
 
Responsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da WebResponsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da WebEduardo Shiota Yasuda
 
Quick ref capybara
Quick ref capybaraQuick ref capybara
Quick ref capybarafatec
 
Frameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPFrameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPDan Jesus
 
WordPress Configuration tips
WordPress Configuration tipsWordPress Configuration tips
WordPress Configuration tipsMasharul Pamir
 
Building a theming system with React - Matteo Ronchi - Codemotion Rome 2017
Building a theming system with React - Matteo Ronchi - Codemotion Rome 2017Building a theming system with React - Matteo Ronchi - Codemotion Rome 2017
Building a theming system with React - Matteo Ronchi - Codemotion Rome 2017Codemotion
 

Mais procurados (19)

Apostrophe
ApostropheApostrophe
Apostrophe
 
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) BootstrapАндрей Юртаев - Improve theming with (Twitter) Bootstrap
Андрей Юртаев - Improve theming with (Twitter) Bootstrap
 
Laying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme developmentLaying the proper foundation for plugin and theme development
Laying the proper foundation for plugin and theme development
 
Login and Registration form using oop in php
Login and Registration form using oop in phpLogin and Registration form using oop in php
Login and Registration form using oop in php
 
Functional testing with capybara
Functional testing with capybaraFunctional testing with capybara
Functional testing with capybara
 
Image Manipulation in WordPress 3.5 - WordCamp Phoenix 2013
Image Manipulation in WordPress 3.5 - WordCamp Phoenix 2013Image Manipulation in WordPress 3.5 - WordCamp Phoenix 2013
Image Manipulation in WordPress 3.5 - WordCamp Phoenix 2013
 
Make your own wp cli command in 10min
Make your own wp cli command in 10minMake your own wp cli command in 10min
Make your own wp cli command in 10min
 
How to make a WordPress theme
How to make a WordPress themeHow to make a WordPress theme
How to make a WordPress theme
 
Introduction to ZendX jQuery
Introduction to ZendX jQueryIntroduction to ZendX jQuery
Introduction to ZendX jQuery
 
Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5Laravel 로 배우는 서버사이드 #5
Laravel 로 배우는 서버사이드 #5
 
Video
VideoVideo
Video
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
15.exemplu complet eloquent view add-edit-delete-search
15.exemplu complet eloquent view add-edit-delete-search15.exemplu complet eloquent view add-edit-delete-search
15.exemplu complet eloquent view add-edit-delete-search
 
Build a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ TelerikBuild a WordPress theme from HTML5 template @ Telerik
Build a WordPress theme from HTML5 template @ Telerik
 
Responsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da WebResponsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da Web
 
Quick ref capybara
Quick ref capybaraQuick ref capybara
Quick ref capybara
 
Frameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPFrameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHP
 
WordPress Configuration tips
WordPress Configuration tipsWordPress Configuration tips
WordPress Configuration tips
 
Building a theming system with React - Matteo Ronchi - Codemotion Rome 2017
Building a theming system with React - Matteo Ronchi - Codemotion Rome 2017Building a theming system with React - Matteo Ronchi - Codemotion Rome 2017
Building a theming system with React - Matteo Ronchi - Codemotion Rome 2017
 

Semelhante a 18. images in symfony 4

How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic templatevathur
 
How To Write Your First Firefox Extension
How To Write Your First Firefox ExtensionHow To Write Your First Firefox Extension
How To Write Your First Firefox ExtensionRobert Nyman
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress WebsitesKyle Cearley
 
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 Basic Templates
Joomla Day UK 2009 Basic TemplatesJoomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic TemplatesChris Davenport
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalChandra Prakash Thapa
 
Joomla Beginner Template Presentation
Joomla Beginner Template PresentationJoomla Beginner Template Presentation
Joomla Beginner Template Presentationalledia
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemAzharul Haque Shohan
 
Build and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsBuild and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsPlasterdog Web Design
 
Refresh Austin - Intro to Dexy
Refresh Austin - Intro to DexyRefresh Austin - Intro to Dexy
Refresh Austin - Intro to Dexyananelson
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Paul Bearne
 
Installing And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogInstalling And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogigorgentry
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsAlessandro Molina
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction PresentationNerd Tzanetopoulos
 

Semelhante a 18. images in symfony 4 (20)

How to create a basic template
How to create a basic templateHow to create a basic template
How to create a basic template
 
How To Write Your First Firefox Extension
How To Write Your First Firefox ExtensionHow To Write Your First Firefox Extension
How To Write Your First Firefox Extension
 
Building Potent WordPress Websites
Building Potent WordPress WebsitesBuilding Potent WordPress Websites
Building Potent WordPress Websites
 
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 Basic Templates
Joomla Day UK 2009 Basic TemplatesJoomla Day UK 2009 Basic Templates
Joomla Day UK 2009 Basic Templates
 
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 NepalWordPress theme development from scratch : ICT MeetUp 2013 Nepal
WordPress theme development from scratch : ICT MeetUp 2013 Nepal
 
9. lower in Symfony 4
9. lower in Symfony 49. lower in Symfony 4
9. lower in Symfony 4
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
Joomla Beginner Template Presentation
Joomla Beginner Template PresentationJoomla Beginner Template Presentation
Joomla Beginner Template Presentation
 
Creating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login SystemCreating a Simple PHP and MySQL-Based Login System
Creating a Simple PHP and MySQL-Based Login System
 
Build and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block PatternsBuild and save your own Gutenberg Block Patterns
Build and save your own Gutenberg Block Patterns
 
Refresh Austin - Intro to Dexy
Refresh Austin - Intro to DexyRefresh Austin - Intro to Dexy
Refresh Austin - Intro to Dexy
 
lab56_db
lab56_dblab56_db
lab56_db
 
lab56_db
lab56_dblab56_db
lab56_db
 
PhpBB meets Symfony2
PhpBB meets Symfony2PhpBB meets Symfony2
PhpBB meets Symfony2
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
 
Installing And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blogInstalling And Configuration for your Wordpress blog
Installing And Configuration for your Wordpress blog
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
 

Mais de 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
 
13. view data
13. view data13. view data
13. view data
 
12.doctrine view data
12.doctrine view data12.doctrine view data
12.doctrine view data
 
11. move in Symfony 4
11. move in Symfony 411. move in Symfony 4
11. move in Symfony 4
 
10. add in Symfony 4
10. add in Symfony 410. add in Symfony 4
10. add in Symfony 4
 

Último

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
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
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
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
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 

Último (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
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
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
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
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
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
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 

18. images in symfony 4

  • 2. • composer create-project symfony/website-skeleton symfony11 • cd symfony11 Install doctrine: • composer require doctrine maker In .env modificati linia: DATABASE_URL=mysql://db_user:db_password@127.0.0.1:3306/db_ name astfel: DATABASE_URL=mysql://root@127.0.0.1:3306/images Porniti serverul MySQL in XAMPP. Pentru a crea db flowers, scrieti in fereastra consola: • php bin/console doctrine:database:create Pentru a crea o “entitate”(MODELUL!) care va gestiona datele unei tabele (care urmeaza a fi creata) vom scrie: php bin/console make:entity Image
  • 3. Fiecare proprietate a clasei Image poate fi asociata cu un camp al tabelei image. Aceasta clasa are definite cateva proprietati private si metodele publice get si set pentru gestionarea acestora. Dorim ca tabela image sa aiba campurile: - id(int, primary key, autoincrement), – nume(varchar(100)) – poza(varchar(100)) Modificam /src/Flower/Entity.php astfel:
  • 4. /src/Flower/Entity.php <?php namespace AppEntity; use DoctrineORMMapping as ORM; /** * @ORMEntity(repositoryClass="AppRepositoryFlowerRepository") */ class Flower { /** * @ORMId() * @ORMGeneratedValue() * @ORMColumn(type="integer") */ private $id; /** * @ORMColumn(type="string", length=100) */ private $nume;
  • 5. /** * @ORMColumn(type="string", length=100) */ private $culoare; public function getId() { return $this->id; } public function getNume() { return $this->nume; } public function getPoza() { return $this->poza; }
  • 6. public function setId($id) { return $this->id=$id; } public function setNume($nume) { return $this->nume=$nume; } public function setPoza($poza) { return $this->poza=$poza; } }
  • 7. • Pentru a genera tabela image, va trebui sa generam mai intati fisierul de migrari: • php bin/console doctrine:migrations:diff • Pentru a crea efectiv tabela, scriem: php bin/console doctrine:migrations:migrate
  • 8.
  • 9.
  • 10. • php bin/console make:controller >DefaultController
  • 11. 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>
  • 12. Vederea default/index.html.twig {% extends 'base.html.twig' %} {% block body %} <table> <tr> <th>Nume</th> <th>Poza</th> <th colspan="3">Actions</th> </tr> {% for key in images %} <tr> <td>{{ key.nume }}</td> <td><img src="/images/{{ key.poza }}" width="100" height="100"></td> <td><a href="{{ app.request.baseUrl() }}/show/{{key.id}}">View</a> <a href="{{ app.request.baseUrl() }}/edit/{{key.id}}">Edit</a> <a href="{{ app.request.baseUrl() }}/delete/{{key.id}}" onclick="return confirm('Are you sure you want to delete this item?');">Delete</a> </td> </tr> {% endfor %} </table> <a href="{{ app.request.baseUrl() }}/add">Insert a record</a> {% endblock %}
  • 13. Controller-ul DefaultController <?php namespace AppController; use SymfonyComponentRoutingAnnotationRoute; use SymfonyBundleFrameworkBundleControllerController; use AppEntityImage; class DefaultController extends Controller { /** * @Route("/", name="default") */ public function index() { $images = $this->getDoctrine()-> getRepository(Image::class)->findAll(); // replace this example code with whatever you need return $this->render('default/index.html.twig', array('images'=>$images)); } }
  • 14. • In tabela image adaugam: • In /public cream directorul /images, in care salvam pozele kali.jpg, lemon.jpg, uaic.jpg, orange.jpg.