Slide 1

Slide 1 text

Un framework PHP robuste et moderne Geoffrey Bachelet – Pandanova mercredi 5 septembre 12

Slide 2

Slide 2 text

HTTP MVC INJECTION DE DÉPENDANCE COMPOSANTS BUNDLES CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 3

Slide 3 text

HTTP mercredi 5 septembre 12

Slide 4

Slide 4 text

HTTP Quel est le cycle de vie d’une page web ? mercredi 5 septembre 12

Slide 5

Slide 5 text

Requête Réponse HTTP mercredi 5 septembre 12

Slide 6

Slide 6 text

Requête Réponse Application HTTP mercredi 5 septembre 12

Slide 7

Slide 7 text

Requête Réponse Application GET HTTP mercredi 5 septembre 12

Slide 8

Slide 8 text

Requête Réponse Application GET POST HTTP mercredi 5 septembre 12

Slide 9

Slide 9 text

Requête Réponse Application GET POST PUT HTTP mercredi 5 septembre 12

Slide 10

Slide 10 text

Requête Réponse Application GET POST PUT DELETE HTTP mercredi 5 septembre 12

Slide 11

Slide 11 text

Requête Réponse Application GET POST PUT DELETE ... HTTP mercredi 5 septembre 12

Slide 12

Slide 12 text

Requête Réponse Application GET POST PUT DELETE ... HTML HTTP mercredi 5 septembre 12

Slide 13

Slide 13 text

Requête Réponse Application GET POST PUT DELETE ... HTML XML HTTP mercredi 5 septembre 12

Slide 14

Slide 14 text

Requête Réponse Application GET POST PUT DELETE ... HTML XML JSON HTTP mercredi 5 septembre 12

Slide 15

Slide 15 text

Requête Réponse Application GET POST PUT DELETE ... HTML XML JSON ... HTTP mercredi 5 septembre 12

Slide 16

Slide 16 text

Tirer parti du protocole HTTP HTTP mercredi 5 septembre 12

Slide 17

Slide 17 text

Codes d’état (200, 404, ...) Tirer parti du protocole HTTP HTTP mercredi 5 septembre 12

Slide 18

Slide 18 text

Codes d’état (200, 404, ...) Redirections Tirer parti du protocole HTTP HTTP mercredi 5 septembre 12

Slide 19

Slide 19 text

Codes d’état (200, 404, ...) Redirections Verbes (GET, POST, ...) Tirer parti du protocole HTTP HTTP mercredi 5 septembre 12

Slide 20

Slide 20 text

Codes d’état (200, 404, ...) Redirections Verbes (GET, POST, ...) Cache (etags, validation, ...) Tirer parti du protocole HTTP HTTP mercredi 5 septembre 12

Slide 21

Slide 21 text

Codes d’état (200, 404, ...) Redirections Verbes (GET, POST, ...) Cache (etags, validation, ...) Négociation de contenu Tirer parti du protocole HTTP HTTP mercredi 5 septembre 12

Slide 22

Slide 22 text

Codes d’état (200, 404, ...) Redirections Verbes (GET, POST, ...) Cache (etags, validation, ...) Négociation de contenu ... Tirer parti du protocole HTTP HTTP mercredi 5 septembre 12

Slide 23

Slide 23 text

Documentation : http://symfony.com/doc/current/book/http_fundamentals.html Composant : http://symfony.com/doc/current/components/http_foundation/ introduction.html HTTP mercredi 5 septembre 12

Slide 24

Slide 24 text

MVC mercredi 5 septembre 12

Slide 25

Slide 25 text

MVC mercredi 5 septembre 12

Slide 26

Slide 26 text

La couche modèle MVC mercredi 5 septembre 12

Slide 27

Slide 27 text

title, 0, 15); } } http://doctrine-project.org/ MVC mercredi 5 septembre 12

Slide 28

Slide 28 text

title, 0, 15); } } http://doctrine-project.org/ MVC Données mercredi 5 septembre 12

Slide 29

Slide 29 text

title, 0, 15); } } http://doctrine-project.org/ MVC Métier mercredi 5 septembre 12

Slide 30

Slide 30 text

http://propelorm.org/ MVC mercredi 5 septembre 12

Slide 31

Slide 31 text

http://propelorm.org/ MVC Données mercredi 5 septembre 12

Slide 32

Slide 32 text

title, 0, 15); } } http://propelorm.org/ MVC mercredi 5 septembre 12

Slide 33

Slide 33 text

title, 0, 15); } } http://propelorm.org/ MVC Métier mercredi 5 septembre 12

Slide 34

Slide 34 text

La couche vue MVC mercredi 5 septembre 12

Slide 35

Slide 35 text

{% extends 'layout.html.twig' %} {% for post in posts %}

{{ post.title }}

{{ post.body | markdown }}
{% endfor %} Twig http://twig.sensiolabs.org/ MVC mercredi 5 septembre 12

Slide 36

Slide 36 text

{% extends 'layout.html.twig' %} {% for post in posts %}

{{ post.title }}

{{ post.body | markdown }}
{% endfor %} http://twig.sensiolabs.org/ MVC Layout mercredi 5 septembre 12

Slide 37

Slide 37 text

{% extends 'layout.html.twig' %} {% for post in posts %}

{{ post.title }}

{{ post.body | markdown }}
{% endfor %} http://twig.sensiolabs.org/ MVC Boucles mercredi 5 septembre 12

Slide 38

Slide 38 text

{% extends 'layout.html.twig' %} {% for post in posts %}

{{ post.title }}

{{ post.body | markdown }}
{% endfor %} http://twig.sensiolabs.org/ MVC Variables mercredi 5 septembre 12

Slide 39

Slide 39 text

{% extends 'layout.html.twig' %} {% for post in posts %}

{{ post.title }}

{{ post.body | markdown }}
{% endfor %} http://twig.sensiolabs.org/ MVC Filtres mercredi 5 septembre 12

Slide 40

Slide 40 text

Le contrôleur MVC mercredi 5 septembre 12

Slide 41

Slide 41 text

render('MyBundle:Post:list', array( 'posts' => PostQuery::create()->find() )); } } MVC mercredi 5 septembre 12

Slide 42

Slide 42 text

render('MyBundle:Post:list', array( 'posts' => PostQuery::create()->find() )); } } MVC Template mercredi 5 septembre 12

Slide 43

Slide 43 text

render('MyBundle:Post:list', array( 'posts' => PostQuery::create()->find() )); } } MVC Données mercredi 5 septembre 12

Slide 44

Slide 44 text

Logique métier encapsulée Facilement testable Facilement maintenable MVC mercredi 5 septembre 12

Slide 45

Slide 45 text

INJECTION DE DÉPENDANCE mercredi 5 septembre 12

Slide 46

Slide 46 text

class User { public function __construct() { $this->storage = new SessionStorage('SESSION_ID'); } public function setLanguage($language) { $this->storage->set('language', $language); } } $user = new User(); INJECTION DE DÉPENDANCE mercredi 5 septembre 12

Slide 47

Slide 47 text

class User { public function __construct() { $this->storage = new SessionStorage('SESSION_ID'); } public function setLanguage($language) { $this->storage->set('language', $language); } } $user = new User(); INJECTION DE DÉPENDANCE Dépendance forte mercredi 5 septembre 12

Slide 48

Slide 48 text

class User { private $storage; public function __construct(StorageInterface $storage) { $this->storage = $storage; } } $storage = new SessionStorage('SESSION_ID'); $user = new User($storage); INJECTION DE DÉPENDANCE Injection mercredi 5 septembre 12

Slide 49

Slide 49 text

class User { private $storage; public function __construct(StorageInterface $storage) { $this->storage = $storage; } } $storage = new SessionStorage('my_session_name'); $user = new User($storage); INJECTION DE DÉPENDANCE mercredi 5 septembre 12

Slide 50

Slide 50 text

class User { private $storage; public function __construct(StorageInterface $storage) { $this->storage = $storage; } } $storage = new MemcacheStorage(); $user = new User($storage); INJECTION DE DÉPENDANCE mercredi 5 septembre 12

Slide 51

Slide 51 text

class User { private $storage; public function __construct(StorageInterface $storage) { $this->storage = $storage; } } $storage = new MemcacheStorage($memcacheClient); $user = new User($storage); INJECTION DE DÉPENDANCE mercredi 5 septembre 12

Slide 52

Slide 52 text

http://www.slideshare.net/fabpot/dependency-injection-in-php-5354 Flexible Configurable Découplé INJECTION DE DÉPENDANCE mercredi 5 septembre 12

Slide 53

Slide 53 text

COMPOSANTS mercredi 5 septembre 12

Slide 54

Slide 54 text

COMPOSANTS ClassLoader Config Console DependencyInjection EventDispatcher Finder Form HttpFoundation Locale Process Routing Security Templating Validation YAML ... mercredi 5 septembre 12

Slide 55

Slide 55 text

CLASSLOADER mercredi 5 septembre 12

Slide 56

Slide 56 text

CLASSLOADER “Autoloading” respectant le standard PSR-0 https://github.com/php-fig/fig-standards/blob/master/accepted/ PSR-0.md COMPOSANTS mercredi 5 septembre 12

Slide 57

Slide 57 text

CLASSLOADER registerNamespaces(array( 'Symfony' => __DIR__.'/../vendor/symfony/src', 'Monolog' => __DIR__.'/../vendor/monolog/src', )); $loader->registerPrefixes(array( 'Swift_' => __DIR__.'/vendor/swiftmailer/lib/classes', 'Twig_' => __DIR__.'/vendor/twig/lib', )); $loader->register(); COMPOSANTS mercredi 5 septembre 12

Slide 58

Slide 58 text

CLASSLOADER registerNamespaces(array( 'Symfony' => __DIR__.'/../vendor/symfony/src', 'Monolog' => __DIR__.'/../vendor/monolog/src', )); $loader->registerPrefixes(array( 'Swift_' => __DIR__.'/vendor/swiftmailer/lib/classes', 'Twig_' => __DIR__.'/vendor/twig/lib', )); $loader->register(); COMPOSANTS Namespaces mercredi 5 septembre 12

Slide 59

Slide 59 text

CLASSLOADER registerNamespaces(array( 'Symfony' => __DIR__.'/../vendor/symfony/src', 'Monolog' => __DIR__.'/../vendor/monolog/src', )); $loader->registerPrefixes(array( 'Swift_' => __DIR__.'/vendor/swiftmailer/lib/classes', 'Twig_' => __DIR__.'/vendor/twig/lib', )); $loader->register(); COMPOSANTS Préfixes mercredi 5 septembre 12

Slide 60

Slide 60 text

CONFIG mercredi 5 septembre 12

Slide 61

Slide 61 text

CONFIG Gestion avancée de configuration COMPOSANTS mercredi 5 septembre 12

Slide 62

Slide 62 text

CONFIG Gestion avancée de configuration Chargement de fichiers de configuration COMPOSANTS mercredi 5 septembre 12

Slide 63

Slide 63 text

CONFIG Gestion avancée de configuration Chargement de fichiers de configuration Mise en cache de la configuration COMPOSANTS mercredi 5 septembre 12

Slide 64

Slide 64 text

CONFIG Gestion avancée de configuration Chargement de fichiers de configuration Mise en cache de la configuration Définition du format de configuration COMPOSANTS mercredi 5 septembre 12

Slide 65

Slide 65 text

CONFIG Gestion avancée de configuration Chargement de fichiers de configuration Mise en cache de la configuration Définition du format de configuration Multi-source (fichiers, base de données) COMPOSANTS mercredi 5 septembre 12

Slide 66

Slide 66 text

CONFIG Gestion avancée de configuration Chargement de fichiers de configuration Mise en cache de la configuration Définition du format de configuration Multi-source (fichiers, base de données) Multi-format (YAML, XML, JSON) COMPOSANTS mercredi 5 septembre 12

Slide 67

Slide 67 text

CONSOLE mercredi 5 septembre 12

Slide 68

Slide 68 text

CONSOLE COMPOSANTS mercredi 5 septembre 12

Slide 69

Slide 69 text

CONSOLE COMPOSANTS mercredi 5 septembre 12

Slide 70

Slide 70 text

CONSOLE options COMPOSANTS mercredi 5 septembre 12

Slide 71

Slide 71 text

CONSOLE options argument COMPOSANTS mercredi 5 septembre 12

Slide 72

Slide 72 text

CONSOLE options argument valeur par défaut COMPOSANTS mercredi 5 septembre 12

Slide 73

Slide 73 text

DEPENDENCYINJECTION mercredi 5 septembre 12

Slide 74

Slide 74 text

DEPENDENCYINJECTION parameters: mailer.transport: sendmail services: mailer: class: Mailer arguments: [%mailer.transport%] newsletter_manager: class: NewsletterManager calls: - [ setMailer, [ @mailer ] ] COMPOSANTS mercredi 5 septembre 12

Slide 75

Slide 75 text

DEPENDENCYINJECTION parameters: mailer.transport: sendmail services: mailer: class: Mailer arguments: [%mailer.transport%] newsletter_manager: class: NewsletterManager calls: - [ setMailer, [ @mailer ] ] COMPOSANTS mercredi 5 septembre 12

Slide 76

Slide 76 text

DEPENDENCYINJECTION parameters: mailer.transport: sendmail services: mailer: class: Mailer arguments: [%mailer.transport%] newsletter_manager: class: NewsletterManager calls: - [ setMailer, [ @mailer ] ] COMPOSANTS Paramètre mercredi 5 septembre 12

Slide 77

Slide 77 text

DEPENDENCYINJECTION parameters: mailer.transport: sendmail services: mailer: class: Mailer arguments: [%mailer.transport%] newsletter_manager: class: NewsletterManager calls: - [ setMailer, [ @mailer ] ] COMPOSANTS Service mercredi 5 septembre 12

Slide 78

Slide 78 text

DEPENDENCYINJECTION use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(__DIR__)); $loader->load('services.yml'); $manager = $container->get('newsletter_manager'); COMPOSANTS mercredi 5 septembre 12

Slide 79

Slide 79 text

DEPENDENCYINJECTION use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(__DIR__)); $loader->load('services.yml'); $manager = $container->get('newsletter_manager'); COMPOSANTS mercredi 5 septembre 12

Slide 80

Slide 80 text

EVENTDISPATCHER mercredi 5 septembre 12

Slide 81

Slide 81 text

EVENTDISPATCHER Implémentation du design pattern “Observer” COMPOSANTS mercredi 5 septembre 12

Slide 82

Slide 82 text

EVENTDISPATCHER use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\Event; $dispatcher = new EventDispatcher(); $dispatcher->addListener('foo.action', function (Event $event) { // will be executed when the foo.action event is dispatched }); $dispatcher->dispatch('foo.action', new Event()); COMPOSANTS mercredi 5 septembre 12

Slide 83

Slide 83 text

EVENTDISPATCHER use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\Event; $dispatcher = new EventDispatcher(); $dispatcher->addListener('foo.action', function (Event $event) { // will be executed when the foo.action event is dispatched }); $dispatcher->dispatch('foo.action', new Event()); COMPOSANTS mercredi 5 septembre 12

Slide 84

Slide 84 text

EVENTDISPATCHER use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\Event; $dispatcher = new EventDispatcher(); $dispatcher->addListener('foo.action', function (Event $event) { // will be executed when the foo.action event is dispatched }); $dispatcher->dispatch('foo.action', new Event()); COMPOSANTS Listener mercredi 5 septembre 12

Slide 85

Slide 85 text

EVENTDISPATCHER use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\Event; $dispatcher = new EventDispatcher(); $dispatcher->addListener('foo.action', function (Event $event) { // will be executed when the foo.action event is dispatched }); $dispatcher->dispatch('foo.action', new Event()); COMPOSANTS Événement mercredi 5 septembre 12

Slide 86

Slide 86 text

FINDER mercredi 5 septembre 12

Slide 87

Slide 87 text

FINDER use Symfony\Component\Finder\Finder; $finder = new Finder(); $finder->files()->in(__DIR__); foreach ($finder as $file) { // Print the absolute path print $file->getRealpath()."\n"; // Print the relative path to the file, omitting the filename print $file->getRelativePath()."\n"; // Print the relative path to the file print $file->getRelativePathname()."\n"; } COMPOSANTS mercredi 5 septembre 12

Slide 88

Slide 88 text

FINDER use Symfony\Component\Finder\Finder; $finder = new Finder(); $finder->files()->in(__DIR__); foreach ($finder as $file) { // Print the absolute path print $file->getRealpath()."\n"; // Print the relative path to the file, omitting the filename print $file->getRelativePath()."\n"; // Print the relative path to the file print $file->getRelativePathname()."\n"; } SplFileInfo COMPOSANTS mercredi 5 septembre 12

Slide 89

Slide 89 text

FINDER use Symfony\Component\Finder\Finder; $finder = new Finder(); $finder->files()->in(__DIR__); foreach ($finder as $file) { // Print the absolute path print $file->getRealpath()."\n"; // Print the relative path to the file, omitting the filename print $file->getRelativePath()."\n"; // Print the relative path to the file print $file->getRelativePathname()."\n"; } COMPOSANTS mercredi 5 septembre 12

Slide 90

Slide 90 text

FINDER use Symfony\Component\Finder\Finder; $finder = new Finder(); $finder->files()->in(__DIR__); foreach ($finder as $file) { // Print the absolute path print $file->getRealpath()."\n"; // Print the relative path to the file, omitting the filename print $file->getRelativePath()."\n"; // Print the relative path to the file print $file->getRelativePathname()."\n"; } COMPOSANTS mercredi 5 septembre 12

Slide 91

Slide 91 text

FINDER use Symfony\Component\Finder\Finder; $finder = new Finder(); $finder->files()->in(__DIR__); foreach ($finder as $file) { // Print the absolute path print $file->getRealpath()."\n"; // Print the relative path to the file, omitting the filename print $file->getRelativePath()."\n"; // Print the relative path to the file print $file->getRelativePathname()."\n"; } COMPOSANTS mercredi 5 septembre 12

Slide 92

Slide 92 text

FINDER Recherche dans plusieurs répertoires COMPOSANTS mercredi 5 septembre 12

Slide 93

Slide 93 text

FINDER Recherche dans plusieurs répertoires Exclusion de répertoire COMPOSANTS mercredi 5 septembre 12

Slide 94

Slide 94 text

FINDER Recherche dans plusieurs répertoires Exclusion de répertoire Recherche sur masques de fichiers COMPOSANTS mercredi 5 septembre 12

Slide 95

Slide 95 text

FINDER Recherche dans plusieurs répertoires Exclusion de répertoire Recherche sur masques de fichiers Recherche par taille COMPOSANTS mercredi 5 septembre 12

Slide 96

Slide 96 text

FINDER Recherche dans plusieurs répertoires Exclusion de répertoire Recherche sur masques de fichiers Recherche par taille Recherche par date COMPOSANTS mercredi 5 septembre 12

Slide 97

Slide 97 text

FINDER Recherche dans plusieurs répertoires Exclusion de répertoire Recherche sur masques de fichiers Recherche par taille Recherche par date Tri standard (nom, type) COMPOSANTS mercredi 5 septembre 12

Slide 98

Slide 98 text

FINDER Recherche dans plusieurs répertoires Exclusion de répertoire Recherche sur masques de fichiers Recherche par taille Recherche par date Tri standard (nom, type) Tri personnalisé (“callback”) COMPOSANTS mercredi 5 septembre 12

Slide 99

Slide 99 text

FINDER Recherche dans plusieurs répertoires Exclusion de répertoire Recherche sur masques de fichiers Recherche par taille Recherche par date Tri standard (nom, type) Tri personnalisé (“callback”) Compatible avec les “streams” PHP COMPOSANTS mercredi 5 septembre 12

Slide 100

Slide 100 text

FINDER Recherche dans plusieurs répertoires Exclusion de répertoire Recherche sur masques de fichiers Recherche par taille Recherche par date Tri standard (nom, type) Tri personnalisé (“callback”) Compatible avec les “streams” PHP ... COMPOSANTS mercredi 5 septembre 12

Slide 101

Slide 101 text

FORM mercredi 5 septembre 12

Slide 102

Slide 102 text

FORM Gestion de formulaires complexes COMPOSANTS mercredi 5 septembre 12

Slide 103

Slide 103 text

FORM Gestion de formulaires complexes Rendu personnalisable via Twig COMPOSANTS mercredi 5 septembre 12

Slide 104

Slide 104 text

FORM Gestion de formulaires complexes Rendu personnalisable via Twig Validation des données COMPOSANTS mercredi 5 septembre 12

Slide 105

Slide 105 text

FORM Gestion de formulaires complexes Rendu personnalisable via Twig Validation des données Encore en beta (prévu pour la 2.1) COMPOSANTS mercredi 5 septembre 12

Slide 106

Slide 106 text

COMPOSANTS ClassLoader Config Console DependencyInjection EventDispatcher Finder Form HttpFoundation Locale Process Routing Security Templating Validation YAML ... mercredi 5 septembre 12

Slide 107

Slide 107 text

“Il y a un composant pour ça” http://symfony.com/doc/current/components/index.html COMPOSANTS mercredi 5 septembre 12

Slide 108

Slide 108 text

BUNDLES mercredi 5 septembre 12

Slide 109

Slide 109 text

BUNDLES “Tout est Bundle !” mercredi 5 septembre 12

Slide 110

Slide 110 text

BUNDLES mercredi 5 septembre 12

Slide 111

Slide 111 text

BUNDLES Bundle mercredi 5 septembre 12

Slide 112

Slide 112 text

BUNDLES Bundle mercredi 5 septembre 12

Slide 113

Slide 113 text

BUNDLES Bundle mercredi 5 septembre 12

Slide 114

Slide 114 text

BUNDLES Bundle mercredi 5 septembre 12

Slide 115

Slide 115 text

Un Bundle peut contenir : BUNDLES mercredi 5 septembre 12

Slide 116

Slide 116 text

Un Bundle peut contenir : Des extensions pour l’injection de dépendance BUNDLES mercredi 5 septembre 12

Slide 117

Slide 117 text

Un Bundle peut contenir : Des extensions pour l’injection de dépendance Des contrôleurs BUNDLES mercredi 5 septembre 12

Slide 118

Slide 118 text

Un Bundle peut contenir : Des extensions pour l’injection de dépendance Des contrôleurs Des gabarits Twig BUNDLES mercredi 5 septembre 12

Slide 119

Slide 119 text

Un Bundle peut contenir : Des extensions pour l’injection de dépendance Des contrôleurs Des gabarits Twig La couche modèle BUNDLES mercredi 5 septembre 12

Slide 120

Slide 120 text

Un Bundle peut contenir : Des extensions pour l’injection de dépendance Des contrôleurs Des gabarits Twig La couche modèle Tout le nécessaire pour votre application BUNDLES mercredi 5 septembre 12

Slide 121

Slide 121 text

Un moyen efficace de structurer du code BUNDLES mercredi 5 septembre 12

Slide 122

Slide 122 text

Un moyen efficace de partager du code BUNDLES mercredi 5 septembre 12

Slide 123

Slide 123 text

BUNDLES mercredi 5 septembre 12

Slide 124

Slide 124 text

BUNDLES 1611 Bundles ! mercredi 5 septembre 12

Slide 125

Slide 125 text

AsseticBundle BUNDLES mercredi 5 septembre 12

Slide 126

Slide 126 text

AsseticBundle AvalancheImagineBundle BUNDLES mercredi 5 septembre 12

Slide 127

Slide 127 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle BUNDLES mercredi 5 septembre 12

Slide 128

Slide 128 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle FOSRestBundle BUNDLES mercredi 5 septembre 12

Slide 129

Slide 129 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle FOSRestBundle FOSUserBundle BUNDLES mercredi 5 septembre 12

Slide 130

Slide 130 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle FOSRestBundle FOSUserBundle GravatarBundle BUNDLES mercredi 5 septembre 12

Slide 131

Slide 131 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle FOSRestBundle FOSUserBundle GravatarBundle HWIOAuthBundle BUNDLES mercredi 5 septembre 12

Slide 132

Slide 132 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle FOSRestBundle FOSUserBundle GravatarBundle HWIOAuthBundle KnpMenuBundle BUNDLES mercredi 5 septembre 12

Slide 133

Slide 133 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle FOSRestBundle FOSUserBundle GravatarBundle HWIOAuthBundle KnpMenuBundle KnpRadBundle BUNDLES mercredi 5 septembre 12

Slide 134

Slide 134 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle FOSRestBundle FOSUserBundle GravatarBundle HWIOAuthBundle KnpMenuBundle KnpRadBundle RabbitMqBundle BUNDLES mercredi 5 septembre 12

Slide 135

Slide 135 text

AsseticBundle AvalancheImagineBundle FOSCommentBundle FOSRestBundle FOSUserBundle GravatarBundle HWIOAuthBundle KnpMenuBundle KnpRadBundle RabbitMqBundle ... BUNDLES mercredi 5 septembre 12

Slide 136

Slide 136 text

“Il y a un Bundle pour ça !” http://knpbundles.com/ BUNDLES mercredi 5 septembre 12

Slide 137

Slide 137 text

CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 138

Slide 138 text

CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 139

Slide 139 text

// src/Acme/DemoBundle/Tests/Utility/CalculatorTest.php namespace Acme\DemoBundle\Tests\Utility; use Acme\DemoBundle\Utility\Calculator; class CalculatorTest extends \PHPUnit_Framework_TestCase { public function testAdd() { $calc = new Calculator(); $result = $calc->add(30, 12); // assert that our calculator added the numbers correctly! $this->assertEquals(42, $result); } } CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 140

Slide 140 text

CONTRÔLE QUALITÉ Barre verte ! mercredi 5 septembre 12

Slide 141

Slide 141 text

CONTRÔLE QUALITÉ Seulement une partie des tests mercredi 5 septembre 12

Slide 142

Slide 142 text

http://phpunit.de/ CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 143

Slide 143 text

Tests fonctionnels CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 144

Slide 144 text

// src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php namespace Acme\DemoBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class DemoControllerTest extends WebTestCase { public function testIndex() { $client = static::createClient(); $crawler = $client->request('GET', '/demo/hello/Fabien'); $count = $crawler ->filter('html:contains("Hello Fabien")') ->count(); $this->assertGreaterThan(0, $count); } } CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 145

Slide 145 text

// src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php namespace Acme\DemoBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class DemoControllerTest extends WebTestCase { public function testIndex() { $client = static::createClient(); $crawler = $client->request('GET', '/demo/hello/Fabien'); $count = $crawler ->filter('html:contains("Hello Fabien")') ->count(); $this->assertGreaterThan(0, $count); } } CONTRÔLE QUALITÉ Navigateur mercredi 5 septembre 12

Slide 146

Slide 146 text

// src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php namespace Acme\DemoBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class DemoControllerTest extends WebTestCase { public function testIndex() { $client = static::createClient(); $crawler = $client->request('GET', '/demo/hello/Fabien'); $count = $crawler ->filter('html:contains("Hello Fabien")') ->count(); $this->assertGreaterThan(0, $count); } } CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 147

Slide 147 text

// src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php namespace Acme\DemoBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class DemoControllerTest extends WebTestCase { public function testIndex() { $client = static::createClient(); $crawler = $client->request('GET', '/demo/hello/Fabien'); $count = $crawler ->filter('html:contains("Hello Fabien")') ->count(); $this->assertGreaterThan(0, $count); } } CONTRÔLE QUALITÉ Assertion mercredi 5 septembre 12

Slide 148

Slide 148 text

CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 149

Slide 149 text

“A PHP framework for testing your business expectations.” CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 150

Slide 150 text

Feature: buy an article In order to be happy As a consumer I want to be able to buy something Scenario: Given I am on the homepage When I search for "fridge" And I follow "Awesome Fridge" And I add the article to my cart And I follow "checkout" # steps that describe the checkout process Then I should see "Your order is complete!" And I should be happy to have a new fridge CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 151

Slide 151 text

Feature: buy an article In order to be happy As a consumer I want to be able to buy something Scenario: Given I am on the homepage When I search for "fridge" And I follow "Awesome Fridge" And I add the article to my cart And I follow "checkout" # steps that describe the checkout process Then I should see "Your order is complete!" And I should be happy to have a new fridge CONTRÔLE QUALITÉ Step mercredi 5 septembre 12

Slide 152

Slide 152 text

CONTRÔLE QUALITÉ /** * @When /^I search for "(?P[^"]*)"$/ */ public function iSearchFor($term) { $this->fillField('Search', $term); $this->pressButton('Find'); } mercredi 5 septembre 12

Slide 153

Slide 153 text

CONTRÔLE QUALITÉ Extensible mercredi 5 septembre 12

Slide 154

Slide 154 text

CONTRÔLE QUALITÉ Extensible Support de Selenium 1/2, ZombieJS, etc mercredi 5 septembre 12

Slide 155

Slide 155 text

CONTRÔLE QUALITÉ Extensible Support de Selenium 1/2, ZombieJS, etc Extension Symfony 2 mercredi 5 septembre 12

Slide 156

Slide 156 text

http://behat.org/ CONTRÔLE QUALITÉ mercredi 5 septembre 12

Slide 157

Slide 157 text

RÉSUMÉ mercredi 5 septembre 12

Slide 158

Slide 158 text

HTTP mercredi 5 septembre 12

Slide 159

Slide 159 text

HTTP Design Pattern MVC mercredi 5 septembre 12

Slide 160

Slide 160 text

HTTP Design Pattern MVC Injection de dependance mercredi 5 septembre 12

Slide 161

Slide 161 text

HTTP Design Pattern MVC Injection de dependance Composants mercredi 5 septembre 12

Slide 162

Slide 162 text

HTTP Design Pattern MVC Injection de dependance Composants Bundles mercredi 5 septembre 12

Slide 163

Slide 163 text

HTTP Design Pattern MVC Injection de dependance Composants Bundles Contrôle qualité mercredi 5 septembre 12

Slide 164

Slide 164 text

Documentation complète mercredi 5 septembre 12

Slide 165

Slide 165 text

Documentation complète Sur le “framework” mercredi 5 septembre 12

Slide 166

Slide 166 text

Documentation complète Sur le “framework” Par composant mercredi 5 septembre 12

Slide 167

Slide 167 text

Documentation complète Sur le “framework” Par composant “Cookbooks” mercredi 5 septembre 12

Slide 168

Slide 168 text

plus de 100 contributeurs mercredi 5 septembre 12

Slide 169

Slide 169 text

plus de 1600 bundles mercredi 5 septembre 12

Slide 170

Slide 170 text

Drupal mercredi 5 septembre 12

Slide 171

Slide 171 text

Drupal PHPBB mercredi 5 septembre 12

Slide 172

Slide 172 text

Drupal PHPBB Symfony-CMF / PHPCR mercredi 5 septembre 12

Slide 173

Slide 173 text

Drupal PHPBB Symfony-CMF / PHPCR Midgard / MIDCOM mercredi 5 septembre 12

Slide 174

Slide 174 text

Drupal PHPBB Symfony-CMF / PHPCR Midgard / MIDCOM ... mercredi 5 septembre 12

Slide 175

Slide 175 text

Pourquoi pas vous ? mercredi 5 septembre 12

Slide 176

Slide 176 text

Geoffrey Bachelet https://github.com/ubermuda https://twitter.com/ubermuda http://pandanova.com/ http://knplabs.ca/ [email protected] mercredi 5 septembre 12

Slide 177

Slide 177 text

Geoffrey Bachelet https://github.com/ubermuda https://twitter.com/ubermuda http://pandanova.com/ http://knplabs.ca/ [email protected] WE’RE