The document provides an overview of Swagger 2.0 and how it can be used to define REST APIs. Swagger allows both humans and computers to understand APIs without access to code or documentation. It includes a specification and tools like an editor, code generation, and UI. The document demonstrates defining a sample DEMO API in Swagger format and generating interactive documentation with Swagger UI. It also introduces PySwagger for testing APIs based on their Swagger definition.
- JWT tokens can be attacked by exploiting vulnerabilities in how they are validated and used. Common attacks include modifying token properties like the signing algorithm, injection of header parameters like kid and x5u, and cracking weak HS256 keys.
- Tools like jwtbrute and libraries that don't properly validate tokens can aid exploitation. Attackers aim to have their tampered tokens treated as authentic by compromising validation processes.
- Developers must carefully validate all token properties, use strong signing keys, and avoid deserialization that doesn't verify signatures to prevent exploitation of JWT tokens.
The document provides an overview of RESTful web services compared to SOAP web services. It discusses how REST is based on the architectural constraints of the web and uses HTTP methods to perform CRUD operations on resources. It also covers the core concepts of REST including resources, representations, and the REST constraints of being stateless, cacheable, etc. Examples are given of how RESTful services can use HTTP features like conditional GET requests and security mechanisms. Frameworks for building RESTful services and comparisons with SOAP are also summarized.
Swagger is a specification and complete framework implementation for describing, producing, consuming, and visualizing RESTful web services. The overarching goal of Swagger is to enable client and documentation systems to update at the same pace as the server. The documentation of methods, parameters, and models are tightly integrated into the server code, allowing APIs to always stay in sync. With Swagger, deploying managing, and using powerful APIs has never been easier.
The document discusses RESTful APIs and some of their key concepts and design principles. It defines REST as an architectural style for building web APIs and describes six constraints of REST including a uniform interface, statelessness, cacheability, being client-server, having a layered system, and using hypermedia as the engine of application state. It then provides more details on concepts like resources, endpoints, verbs, versioning, authentication, and filtering.
Une riche présentation de Mapping Objet Relationnel qui traite le standard JPA et l’implémentation Hibernate en les intégrant avec le frammework IOC spring.
Simple REST-API overview for developers. An newer version is here: https://www.slideshare.net/patricksavalle/super-simple-introduction-to-restapis-2nd-version-127968966
Presented by Nikola Vasilev on SkopjeTechMeetup 7.
Representational state transfer (REST) can be thought of as the language of the Internet. Now with cloud usage on the rise, REST is a logical choice for building APIs that allow end users to connect and interact with cloud services. This talk will deliver more insight into the challenges on building and maintaining good and clean RESTful APIs.
The document discusses Representational State Transfer (REST) and RESTful web services. It provides an overview of REST principles including treating everything as a resource with a uniform interface, using standard HTTP methods, supporting multiple representations, communicating statelessly through hypermedia, and linking resources together. It then provides examples of how to design a RESTful API for a bookmark management application, mapping operations to resources, URIs, and HTTP methods.
- REST (Representational State Transfer) uses HTTP requests to transfer representations of resources between clients and servers. The format of the representation is determined by the content-type header and the interaction with the resource is determined by the HTTP verb used.
- The four main HTTP verbs are GET, PUT, DELETE, and POST. GET retrieves a representation of the resource and is safe, while PUT, DELETE, and POST can modify the resource's state in atomic operations.
- Resources are abstract concepts acted upon by HTTP requests, while representations are the actual data transmitted in responses. The representation may or may not accurately reflect the resource's current state.
OAuth 2 is an authorization framework that allows applications to access user data and perform actions on their behalf. It defines flows for applications to request access, and provides short-lived credentials in response. The main roles in OAuth are the resource owner (user), client (application), resource server (API), and authorization server (issues tokens). Common grant types include authorization code, implicit, and client credentials flows. Tokens returned include access and refresh tokens, and OpenID Connect adds optional ID tokens containing user information.
The Spring Framework provides a comprehensive Java platform for developing applications. It simplifies development by allowing developers to avoid dealing directly with complex APIs. Spring uses Inversion of Control and Dependency Injection to decouple classes and increase maintainability. The core Spring modules include beans, context, AOP, and aspects. Spring MVC implements the MVC pattern to build web applications, separating the model, view, and controller aspects.
Test in Rest. API testing with the help of Rest Assured.Artem Korchevyi
Presentation for Autumn QC meetup 2018 (UA, Ivano-Frankivsk) about testing REST Api with demo example how to develop tests. Project here - https://github.com/Antracot/TestInRest
How to Build a High Performance Application with PHP and Swoole?Albert Chen
Albert Chen gave a presentation about using Swoole, an extension for PHP, to build high concurrency applications. Swoole provides asynchronous network capabilities that allow PHP applications to have an event-driven, non-blocking architecture. It addresses issues with PHP's blocking I/O and stateless model that limit scalability. Swoole improves performance by keeping the PHP code in memory and handling requests with coroutines instead of processes. While Swoole helps PHP applications achieve higher concurrency, traditional PHP code requires refactoring to fully utilize Swoole's features. Overall, Swoole extends PHP's capabilities for building high performance web applications.
The document discusses stateless authorization using OAuth2 and JSON Web Tokens (JWT). It begins with an introduction to authentication, authorization, and single sign-on (SSO). It then provides an in-depth explanation of OAuth2 actors, flows, and grant types. The Authorization Code Grant flow and Implicit Grant flow are explained in detail. Finally, it introduces JWT and why it is a suitable standard for representing OAuth2 access tokens since it meets the requirements and libraries are available.
This document discusses consuming RESTful APIs using Swagger v2.0. It provides an overview of Swagger and how it can be used to automatically generate client code for APIs in multiple languages like Android and iOS. It also discusses some common issues with code generation and outlines Outware's approach to address these issues, including customizing the code generation, publishing clients as dependencies, and maintaining consistency across platforms.
What is REST API? REST API Concepts and Examples | EdurekaEdureka!
YouTube Link: https://youtu.be/rtWH70_MMHM
** Node.js Certification Training: https://www.edureka.co/nodejs-certification-training **
This Edureka PPT on 'What is REST API?' will help you understand the concept of RESTful APIs and show you the implementation of REST APIs'. Following topics are covered in this REST API tutorial for beginners:
Need for REST API
What is REST API?
Features of REST API
Principles of REST API
Methods of REST API
How to implement REST API?
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This is a presentation which describe the big picture of the Rest API. In this presentation I simply describe the theories with practical examples. Hope this presentation will cover the overall Rest API domain.
This document discusses using Docker and Docker Compose to run a CKAN instance for managing open data. It covers cloning the docker-bodik repository, setting environment variables, bringing up the containers, and extending CKAN with custom plugins.
The document discusses demystifying APIs. It begins with an introduction to APIs, including their evolution and benefits. It then discusses RESTful APIs and their key aspects like uniform interface and use of HTTP methods. The document outlines best practices for API design, development, and challenges. It provides examples of designing APIs using Node.js and Hapi.js and discusses challenges like security, authentication, rate limiting, and scalability. Tools mentioned include Express, Swagger, Postman, and Kong.
An introduction to a popular framework for Service Oriented REST APIs, Proof of Concepts and Rapid Development. Swagger is a indispensable tool for Software Engineers, Developers and Architects.
Spring Web MVC is the original web framework built on the Servlet API and has been included in the Spring Framework from the very beginning. The formal name, “Spring Web MVC,” comes from the name of its source module (spring-webmvc), but it is more commonly known as “Spring MVC”.
Parallel to Spring Web MVC, Spring Framework 5.0 introduced a reactive-stack web framework whose name, “Spring WebFlux,” is also based on its source module (spring-webflux). This section covers Spring Web MVC.
These slides describe how symfony 1 and Symfony2 are RESTful frameworks, and ho to implement RESTful web services in both. The talk was given during Symfony Live 2011 Paris.
For more informations, please see http://symfpony-project.org/
Simple REST-API overview for developers. An newer version is here: https://www.slideshare.net/patricksavalle/super-simple-introduction-to-restapis-2nd-version-127968966
Presented by Nikola Vasilev on SkopjeTechMeetup 7.
Representational state transfer (REST) can be thought of as the language of the Internet. Now with cloud usage on the rise, REST is a logical choice for building APIs that allow end users to connect and interact with cloud services. This talk will deliver more insight into the challenges on building and maintaining good and clean RESTful APIs.
The document discusses Representational State Transfer (REST) and RESTful web services. It provides an overview of REST principles including treating everything as a resource with a uniform interface, using standard HTTP methods, supporting multiple representations, communicating statelessly through hypermedia, and linking resources together. It then provides examples of how to design a RESTful API for a bookmark management application, mapping operations to resources, URIs, and HTTP methods.
- REST (Representational State Transfer) uses HTTP requests to transfer representations of resources between clients and servers. The format of the representation is determined by the content-type header and the interaction with the resource is determined by the HTTP verb used.
- The four main HTTP verbs are GET, PUT, DELETE, and POST. GET retrieves a representation of the resource and is safe, while PUT, DELETE, and POST can modify the resource's state in atomic operations.
- Resources are abstract concepts acted upon by HTTP requests, while representations are the actual data transmitted in responses. The representation may or may not accurately reflect the resource's current state.
OAuth 2 is an authorization framework that allows applications to access user data and perform actions on their behalf. It defines flows for applications to request access, and provides short-lived credentials in response. The main roles in OAuth are the resource owner (user), client (application), resource server (API), and authorization server (issues tokens). Common grant types include authorization code, implicit, and client credentials flows. Tokens returned include access and refresh tokens, and OpenID Connect adds optional ID tokens containing user information.
The Spring Framework provides a comprehensive Java platform for developing applications. It simplifies development by allowing developers to avoid dealing directly with complex APIs. Spring uses Inversion of Control and Dependency Injection to decouple classes and increase maintainability. The core Spring modules include beans, context, AOP, and aspects. Spring MVC implements the MVC pattern to build web applications, separating the model, view, and controller aspects.
Test in Rest. API testing with the help of Rest Assured.Artem Korchevyi
Presentation for Autumn QC meetup 2018 (UA, Ivano-Frankivsk) about testing REST Api with demo example how to develop tests. Project here - https://github.com/Antracot/TestInRest
How to Build a High Performance Application with PHP and Swoole?Albert Chen
Albert Chen gave a presentation about using Swoole, an extension for PHP, to build high concurrency applications. Swoole provides asynchronous network capabilities that allow PHP applications to have an event-driven, non-blocking architecture. It addresses issues with PHP's blocking I/O and stateless model that limit scalability. Swoole improves performance by keeping the PHP code in memory and handling requests with coroutines instead of processes. While Swoole helps PHP applications achieve higher concurrency, traditional PHP code requires refactoring to fully utilize Swoole's features. Overall, Swoole extends PHP's capabilities for building high performance web applications.
The document discusses stateless authorization using OAuth2 and JSON Web Tokens (JWT). It begins with an introduction to authentication, authorization, and single sign-on (SSO). It then provides an in-depth explanation of OAuth2 actors, flows, and grant types. The Authorization Code Grant flow and Implicit Grant flow are explained in detail. Finally, it introduces JWT and why it is a suitable standard for representing OAuth2 access tokens since it meets the requirements and libraries are available.
This document discusses consuming RESTful APIs using Swagger v2.0. It provides an overview of Swagger and how it can be used to automatically generate client code for APIs in multiple languages like Android and iOS. It also discusses some common issues with code generation and outlines Outware's approach to address these issues, including customizing the code generation, publishing clients as dependencies, and maintaining consistency across platforms.
What is REST API? REST API Concepts and Examples | EdurekaEdureka!
YouTube Link: https://youtu.be/rtWH70_MMHM
** Node.js Certification Training: https://www.edureka.co/nodejs-certification-training **
This Edureka PPT on 'What is REST API?' will help you understand the concept of RESTful APIs and show you the implementation of REST APIs'. Following topics are covered in this REST API tutorial for beginners:
Need for REST API
What is REST API?
Features of REST API
Principles of REST API
Methods of REST API
How to implement REST API?
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This is a presentation which describe the big picture of the Rest API. In this presentation I simply describe the theories with practical examples. Hope this presentation will cover the overall Rest API domain.
This document discusses using Docker and Docker Compose to run a CKAN instance for managing open data. It covers cloning the docker-bodik repository, setting environment variables, bringing up the containers, and extending CKAN with custom plugins.
The document discusses demystifying APIs. It begins with an introduction to APIs, including their evolution and benefits. It then discusses RESTful APIs and their key aspects like uniform interface and use of HTTP methods. The document outlines best practices for API design, development, and challenges. It provides examples of designing APIs using Node.js and Hapi.js and discusses challenges like security, authentication, rate limiting, and scalability. Tools mentioned include Express, Swagger, Postman, and Kong.
An introduction to a popular framework for Service Oriented REST APIs, Proof of Concepts and Rapid Development. Swagger is a indispensable tool for Software Engineers, Developers and Architects.
Spring Web MVC is the original web framework built on the Servlet API and has been included in the Spring Framework from the very beginning. The formal name, “Spring Web MVC,” comes from the name of its source module (spring-webmvc), but it is more commonly known as “Spring MVC”.
Parallel to Spring Web MVC, Spring Framework 5.0 introduced a reactive-stack web framework whose name, “Spring WebFlux,” is also based on its source module (spring-webflux). This section covers Spring Web MVC.
These slides describe how symfony 1 and Symfony2 are RESTful frameworks, and ho to implement RESTful web services in both. The talk was given during Symfony Live 2011 Paris.
For more informations, please see http://symfpony-project.org/
This document discusses different types of entities in OroCRM: doctrine entities, configurable entities, and extended entities. Doctrine entities are standard PHP objects that represent database tables. Configurable entities allow configuration of entities and fields through a configuration schema and provider service. Extended entities allow dynamically adding and removing fields to an existing entity through configuration or migrations without changing the source code. Commands like oro:migration:load are used to update the database schema and entity configurations.
OroPlatform and OroCRM from a developer's perspectiveYevhen Shyshkin
This document provides an overview of OroPlatform and OroCRM from a developer's perspective. It describes the backend and frontend MVC structure, Symfony basics like bundles and dependency injection. It also covers key development aspects like Doctrine ORM, entities and extensions, datagrids, workflows, and the developers environment. The goal is to help developers understand the architecture and main components for developing applications on the OroPlatform.
Conference drupal 8 au Forum PHP 2013 à ParisChipway
Conférence sur les nouveautés de Drupal 8 lors du Forum PHP 2013 à Paris.
Léon Cros a parlé de Views, Symfony2, Editeur CKEditor, Édition directe, HTML5, Mobile et smartphones, services web, ...
Présentation utilisée en guise de support lors du Symfony Live 2014 à Paris sur comment migrer rapidement et simplement une application Symfony2 sur Azure. L'exemple se base principalement sur comment migrer son système de stockage de données et sa gestion des fichiers via la mise en place d'un Blob Storage.
L’usage de Symfony2, l’organisation du code et l’usage du projet Sonata chez Canal+ pour répondre aux enjeux de la refonte d’une partie de la plateforme web. La plateforme présente de nombreux challenges techniques : SDK, API privée, API publique restful+hal, création de contenus riches, huit applications différentes avec une base de code commune, etc. Comment il a été possible d’améliorer certaines parties de Sonata ainsi que l’approche choisie pour la création de certains composants transverses.
Symfony2: 30 astuces et bonnes pratiquesNoel GUILBERT
Avec cette nouvelle version de votre framework préféré, de nouvelles fonctionnalités et de nouveaux usages sont apparus. Vous vous demandez comment structurer vos bundles? Comment organiser votre code source? Comment utiliser correctement l'injecteur de dépendance? Venez découvrir au cours de cette session les bonnes pratiques, et quelques astuces, qui vous aiderons dans la réalisation de vos projets avec Symfony2.
Cette présentation donne une idée bien détaillée sur les web services. Elle présente aussi les types de web services(SOAP, REST), et enfin comment les développer dans le langage de programmation java.
Tendances Futures du Web - GTI780 & MTI780 - ETS - A08Claude Coulombe
Présentation sur les tendances futures du Web dans le cadre du cours combiné GTI780 / MTI780, Sujets spéciaux en TI, donné par Claude Coulombe, à l\'Ecole de technologie supérieure, Montréal, Automne 2008
[fr] Introduction et Live-code Backbone.js à DevoxxFR 2013Sylvain Zimmer
Ma session de live-coding à DevoxxFR 2013. Le but était de faire une présentation rapide de Backbone et de montrer très simplement aux gens pourquoi et comment l'utiliser.
Le code que j'ai live-codé est disponible sur https://github.com/sylvinus/backbone-simpleapp-kitlers
Au cours de cette session, nous présenterons d'une manière générale toutes les caractéristiques qui font de symfony un framework open source tourné vers le monde professionnel.
Il s'agira dans un premier temps de montrer que symfony n'est pas seulement une base de code mais un projet open source à part entière disposant d'un écosystème riche sur lequel n'importe quel développeur peut compter.
Nous porterons ensuite un oeil plus attentif aux fonctionnalités phares du framework telles que sa couche d'abstraction de base de données, son interface en ligne de commande, le routing bidirectionnel, les outils de test automatisés ou bien encore le générateur automatique de backoffice.
Découverte de SharePoint Workspace : positionnement et usages du produit, présentation des espaces SharePoint et des espaces Groove. Customization. Architecture et Déploiement.
Présentation créée à l'occasion des Microsoft TechDays en France, le 9 février 2010. Session animée par Fabrice Barbin.
Diaporama diffusé lors du sfPot Lillois du 20 mars 2014.
Conférence animée par Kévin Dunglas, co-fondateur de
Les-Tilleuls.coop et Alexandre Salomé, consultant chez Sensiolabs.
Design Patterns avec PHP 5.3, Symfony et PimpleHugo Hamon
Cette conférence présente deux grands motifs de conception : l'observateur et l'injection de dépendance. Ce sujet allie à la fois théorie et pratique. Le composant autonome EventDispatcher de Symfony ainsi que le conteneur d'injection de dépendance Pimple sont mis à l'honneur avec des exemples pratiques d'usage. Ces cas pratiques combinent du code de l'ORM Propel ainsi que le composant autonome Zend\Search\Lucene du Zend Framework 2
Monitor the quality of your Symfony projectsHugo Hamon
Ensuring an application source code quality is not an easy task. This is especially true with the PHP language, which is still compared to a non-professional programming language nowadays. In fact, the PHP language has plenty of professional tools for monitoring the quality of PHP projects. These tools are also standard enough to be coupled and to communicate with other professional tools in Java for example. In this session, we will introduce some of the Symfony2 best practices to adopt to write clean and maintainable code. Then, we will look at the best PHP quality tools to setup to monitor a Symfony2 project on a day-to-day development. The conference will especially focus on the Jenkins continuous integration platform, automated tests (unit and functional testing) and how to get and interpret metrics on the code.
This session introduces most well known design patterns to build PHP classes and objects that need to store and fetch data from a relational databases. The session will describe the difference between of the Active Record, the Table and Row Data Gateway and the Data Mapper pattern. We will also examine some technical advantages and drawbacks of these implementations. This talk will expose some of the best PHP tools, which ease database interactions and are built on top of these patterns.
Silex is a brand new PHP 5.3 micro framework built on top of the Symfony2 de decoupled components. In this session, we will discover how to build and deploy powerful REST web services with such a micro framework and its embedded tools.
The first part of this talk will introduce the basics of the REST architecture. We fill focus on the main concepts of REST like HTTP methods, URIs and open formats like XML and JSON.
Then, we will discover how to deploy REST services using most of interesting Silex tools like database abstraction layer, template engine and input validation. We will also look at unit and functional testing frameworks with PHPUnit and HTTP caching with Edge Side Includes and Varnish support to improve performances.
This document summarizes the history of PHP persistence from 1995 to present day. It begins with early file handling in PHP/FI in 1995 and the introduction of database support. It then discusses the evolution of code reusability through functions and classes. Professional abstraction layers like PEAR and later ORM frameworks provided more robust and standardized APIs. NoSQL databases and drivers were later incorporated, moving beyond relational databases. Current frameworks provide object document mapping for non-SQL databases like MongoDB.
Intégration Continue PHP avec Jenkins CIHugo Hamon
Comment assurer le suivi qualite du code source d'une application web? Ce n'est pas une tache aisée ! C’est d’autant plus vrai que PHP est encore considéré aujourd'hui comme un langage peu professionnel. PHP est pourtant un langage dont l'outillage n'a rien a envier a l'ensemble de ses concurrents. L'objectif de cette conférence est de présenter les bonnes pratiques à adopter ainsi que les différents outils a mettre en oeuvre afin de contrôler la qualité d'un projet PHP au quotidien. Un focus particulier sera porté sur la plateforme d'intégration continue Jenkins, les tests unitaires ou bien encore la récupération et l'interprétation des métriques collectées.
Symfony2 - extending the console componentHugo Hamon
The goal of this session is to explain how to take benefit from the Symfony2 command line interface tool. First, I have a closer look at the most interesting commands to generate code and help you reduce your development time. Then, I will show you how to create your own commands to extend the Symfony CLI tool and automate your tedious and redundant tasks. This part of the talk will also explain how to create interactive tasks, interact with the database, generating links or send emails from the command line. Of course, there will be a focus on how to design your commands the best way to make them as much testable as possible.
Développeurs, cachez-moi ça ! (Paris Web 2011)Hugo Hamon
L'une des contraintes les plus complexes à résoudre lorsqu'on développe une application web consiste à ne pas générer deux fois la même page. Pour y parvenir, la plupart des développeurs ont recours à des solutions de cache propriétaires qui montrent rapidement leurs limites lorsqu'il s'agit de cacher des pages très dynamiques. Un article et ses commentaires, accompagnés d'un flux Twitter actif par exemple. Heureusement, le protocole HTTP offre depuis très longtemps des outils adaptés pour contrôler la mise en cache côté navigateur. Au cours de cet atelier, nous étudierons tout d'abord les modèles fondamentaux du cache HTTP côté client grâce à l'expiration et la validation. Enfin, nous découvrirons comment améliorer les performances tout en restant le plus dynamique possible grâce aux Edge Side Includes, ESI, et les reverse proxy caches tels que Varnish.
Speed up your developments with Symfony2Hugo Hamon
Symfony2 is a PHP full-stack framework that provides tools and components to speed up web development. It emphasizes separation of concerns, standards compliance, and best practices. Symfony2 allows developers to create Request-Response applications using its routing, templating, validation, forms, database abstraction, and other features in a decoupled and reusable way. It also provides debugging tools, code generators, and other utilities to improve developer productivity.
Symfony2 - Un Framework PHP 5 PerformantHugo Hamon
L’arrivée de PHP 5.3 en milieu d’année 2009 a bouleversé la manière de développer des applications web. En effet, cette nouvelle version a apporté de nouveaux outils au langage tels que les espaces de nommage qui favorisent la réutilisabilité du code lorsqu’ils sont employés à bon escient. Les nouveaux frameworks de développement rapide ont aussi suivi le mouvement et reposent sur la base de PHP 5.3. C’est le cas de Symfony2 dont la version stable est prévue prochainement.
Cette présentation offre un tour d’horizon de la nouvelle architecture du framework qui s’articule autour de “bundles”, de librairies externes et de nombreux composants indépendants tels que le conteneur d’injection de dépendances. Nous dresserons un panorama des principales fonctionnalités offertes par le framework telles que la couche d’ORM Doctrine 2, le moteur de templating Twig et la gestion des formulaires. Nous nous intéresserons également à la gestion du cache HTTP, à la couche de sécurité ainsi qu’aux outils de débogage destinés à améliorer la productivité du développeur et la maintenance de l’application.
Build powerfull and smart web applications with Symfony2Hugo Hamon
Symfony2 first stable release is scheduled for the first week of March 2011. During this session, we will have a look at the new framework architecture and most of its powerfull features.
We will show you how Symfony2 implements the MVC pattern and an HTTP request is processed and converted as a response for the end user. Of course, we will talk about the configuration principles and how it's easy to configure Symfony2 project parts like the routing system or the data model. We will also focus on other major components of the framework like the Doctrine2 integration, forms, security (authentication and authorizations) or HTTP cache management.
Paradoxalement, Symfony2 n'est pas qu'un framework "full-stack". Il s'agit avant tout d'une parfaite synergie de briques logicielles autonomes qui travaillent de concert sous la baguette d'un seul chef d'orchestre : le conteneur d'injection de dépendances. Mais savez-vous que vous pouvez aussi les utiliser sans le framework ? Tous ces composants indépendants sont distribués sous licence MIT et offrent aux développeurs la liberté de les utiliser dans leurs projets PHP. Au cours de cette session, nous mettrons en lumière les fonctionnalités offertes par les principaux composants de Symfony2 tels que DependencyInjection, Console, Finder, EventDispatcher, Translation et bien d'autres encore. Vous découvrirez comment les intégrer et les utiliser dans vos projets PHP, et ainsi devenir le prochain Maestro du web.
Cette nouvelle version du framework a été entièrement réécrite afin de tirer profit de PHP 5.3 d'une part mais également de corriger les erreurs du passé avec symfony 1.x.
Cette nouvelle version regorge de fonctionnalités puissantes pour vous aider à bâtir des applications web maintenables, pérennes, performantes et évolutives.
Cette présentation donne un aperçu des nouvelles fonctionnalités de Symfony2 comme l'architecture MVC, les tests automatisés ou bien encore l'envoi d'emails.
La généalogie assistée par l’IA (G·IA) et ses outils.Erol GIRAUDY
La généalogie assistée par l’intelligence
artificielle (G·IA) et ses outils.
2025 - Auteur : P. Erol GIRAUDY.
Relecteur : Claude SOTROISC.
Editeur : P. Erol GIRAUDY.
Illustration : Erol GIRAUDY et l’IA.
La Généalogie 4.0 désigne, ce qui est à notre sens, la
quatrième révolution technologique de la généalogie, celle
de l’intelligence artificielle. Nous avons choisi le terme de
Généalogie 4.0 en analogie avec l’Industrie 4.01 »
Mon guide sur l'IA et la généalogie format PDF et gratuit.
Mes retours sur l'utilisations d'outils de généalogies. (REX):
https://www.erolgiraudy.eu/p/mes-retours-sur-lutilisations-doutils.html
Il contient toujours toutes les informations importantes sur l'utilisation des IAG en généalogie, organisées selon la méthode QQOQCP :
QUI peut utiliser l'IA en généalogie
QUELS outils d'IA sont utiles pour la généalogie
OÙ utiliser ces outils
QUAND les utiliser
COMMENT les appliquer efficacement
POURQUOI intégrer l'IA à vos recherches généalogiques :
https://claude.ai/public/artifacts/4b2d666d-1e0d-4b82-91fc-945b71771704
GENEANET:
https://gw.geneanet.org/pierreerol_w?lp=0
Cadre d'Apprentissage des IAG pour Généalogistes:
https://uga-ia.blogspot.com/2025/04/cadre-dapprentissage-des-iag-pour.html
Erol GIRAUDY
https://www.erolgiraudy.eu/
https://uga-ia.blogspot.com/
https://www.erolgiraudy.eu/2024/10/mes-15-livres.html
https://and500.blogspot.com/
https://www.ugaia.eu/
Ai EngineHost Review : Hébergement révolutionnaire aux GPU NVIDIA, Datacenter...SOFTTECHHUB
Bienvenue dans cette revue complète d’Ai EngineHost. J’ai eu l’occasion d’expérimenter personnellement cette solution d’hébergement révolutionnaire et je suis ravi de vous en parler. Vous allez découvrir une plateforme basée aux États-Unis, alimentée par des GPU NVIDIA, qui offre une capacité d’hébergement illimitée pour vos sites web, vos applications d’intelligence artificielle et vos noms de domaine. Dans cet article, je décris les fonctionnalités, les avantages, la tarification, et pourquoi ce service est incontournable pour les entrepreneurs du digital.
Exposer des services web SOAP et REST avec symfony 1.4 et Zend Framework
1. Exposer des services web
SOAP et REST
RMLL - 6 juillet 2010
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
2. Qui suis-je ?
❖ Hugo HAMON (@hhamon)
❖ Responsable des formations chez Sensio Labs
❖ Coauteur et contributeur d’ouvrages
❖ Secrétaire Général de l’AFUP
❖ Webmaster du site Apprendre-PHP.com
❖ http://www.hugohamon.com
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
3. Introduction aux Web services
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
4. Les services web
❖ Programmes destinés à échanger des données entre systèmes hétérogènes
❖ Basés sur des standards (SOAP) ou des styles d’architecture (REST)
❖ Fonctionnent en mode Client / Serveur (requête / réponse)
❖ Echange de données préformattées (XML, JSON, YAML, HTML...)
❖ Faible couplage grâce aux standards ouverts comme XML
❖ Faciles à mettre en oeuvre
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
6. REST c’est quoi ?
❖ REpresentational State Transfert
❖ Concept inventé par Roy Fielding en 2000
❖ REST est un style d’architecture !
❖ REST s’appuie sur les concepts suivants :
❖ Le protocole HTTP (requête / réponse)
❖ La notion d’URI qui identifie chaque ressource
❖ Les méthodes HTTP (GET, POST, PUT, DELETE, HEAD)
❖ Les codes de statut (200, 201, 403, 404, 500...)
❖ Les formats ouverts (XML, JSON, HTML...)
❖ REST est simple à mettre en oeuvre
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
7. La notion d’URI dans REST
❖ Chaque URI identifie une ressource
http://api.domain.com/users/hugo
❖ Une URI ne contient pas de verbe !
❖ Une même URI peut être appelée avec différentes méthodes HTTP
GET http://api.domain.com/users Récupère les utilisateurs
POST http://api.domain.com/users Crée un nouvel utilisateur
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
8. Les méthodes HTTP
❖ GET, POST, PUT, DELETE et HEAD
❖ Identifient les actions réalisables sur la ressource
GET http://api.domain.com/users Récupère les utilisateurs
POST http://api.domain.com/users Crée un nouvel utilisateur
PUT http://api.domain.com/users/hugo Modifie hugo
DELETE http://api.domain.com/users/hugo Supprime hugo
❖ Opérations CRUD sur les ressources
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
9. Les codes HTTP de retour
❖ Indiquent l’état (succès ou échec) de l’opération effectuée
Méthodes En cas de succès En cas d’échec
201 Created
POST 400 Bad Request
Redirection vers l’URI de l’objet
400 Bad Request
PUT 200 OK 404 Not Found
409 Conflict
400 Bad Request
DELETE 200 OK 404 Not Found
410 Gone
GET 200 OK 400 Bad Request
404 Not Found
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
10. Symfony
un framework RESTfull
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
12. Présentation de symfony
❖ Framework PHP 5 MVC Open Source « full stack »
❖ Rapid Application Development
❖ Publié en 2005 sous licence MIT
❖ Bâti pour répondre à des besoins complexes
❖ « best practices » (design patterns, mvc, tests unitaires...)
❖ Maintenu par Sensio Labs jusqu’à fin 2012
❖ Documentation riche et Open Source (4 livres officiels)
❖ Communauté très active
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
14. Un routing RESTFull
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
15. Routage de symfony
❖ Symfony découple les URLs du code (implémentation technique)
/blog.php?section=symfony&article_id=18475
/blog/2008-01-30/symfony-happy-new-year
❖ Optimisation pour les moteurs de recherche
❖ URIs faciles à copier / coller, mémoriser ou bookmarker
❖ Masque l’implémentation technique (php, python, ruby ?)
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
16. Contraindre les routes aux méthodes HTTP
❖ sfRequestRoute permet de contraindre les URIs aux méthodes HTTP
❖ Une même URI peut être atteinte avec des méthodes HTTP différentes
user_edit:
class: sfRequestRoute
url: /api/users/:username
param: { module: user, action: update }
requirements: { sf_method: put }
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
17. Contraindre les routes aux méthodes HTTP
$ php symfony app:routes api
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
18. Contraindre les routes aux méthodes HTTP
❖ Symfony simule les requêtes PUT et DELETE depuis un navigateur
❖ Les formulaires embarquent un champ caché « sf_method »
<form action="/api_dev.php/api/user/hugo" method="post">
<input type="hidden" value="put" name="sf_method"/>
<input type="hidden" id="rmll_user_id" value="2" name="rmll_user[id]"/>
<input type="hidden" id="rmll_user__csrf_token"
value="94c132e7c771411590124aea52bb9d4f" name="rmll_user[_csrf_token]"/>
<!-- ... -->
</form>
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
19. Contraindre les routes aux méthodes HTTP
$params = array(
'method' => 'delete',
'confirm' => 'Etes-vous sûr de vouloir supprimer cet objet ?'
);
echo link_to('supprimer', 'user_delete', $object, $params);
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
20. Contraindre les routes aux méthodes HTTP
$params = array(
'method' => 'delete',
'confirm' => 'Etes-vous sûr de vouloir supprimer cet objet ?'
);
echo link_to('supprimer', 'user_delete', $object, $params);
<li class="sf_admin_action_delete"><a href="/api_dev.php/api/user/hugo"
onclick="if (confirm('Are you sure?')) { var f = document.createElement
('form'); f.style.display = 'none'; this.parentNode.appendChild(f);
f.method = 'post'; f.action = this.href;var m = document.createElement
('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name',
'sf_method'); m.setAttribute('value', 'delete'); f.appendChild(m);var m
= document.createElement('input'); m.setAttribute('type', 'hidden');
m.setAttribute('name', '_csrf_token'); m.setAttribute('value',
'f0271a52cca50e62df7deb1568f80489'); f.appendChild(m);f.submit
(); };return false;">Supprimer</a></li>
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
21. Les routes d’objets
user_edit
Route Objet Doctrine RmllUser
Base de données
user_edit:
class: sfDoctrineRoute
url: /api/users/:username
param: { module: user, action: update }
options: { model: RmllUser, column: username, type: object }
requirements: { sf_method: put }
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
22. Les routes d’objets
public function executeUpdate(sfWebRequest $request)
{
$user = $this->getRoute()->getObject();
$form = new RmllUserForm($user, array(), false);
$form->bind($request->getParameter('rmll_user'));
$status = 400;
if ($form->isValid())
{
$form->save();
$status = 200;
}
$this->getResponse()->setStatusCode($status);
return sfView::NONE;
}
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
23. Les collections de routes d’objets
❖ sfDoctrineRouteCollection ou sfPropelRouteCollection
❖ Actions CRUD sur un objet de modèle
user
user_new
user_create
user_edit
user_update
user_delete
user_show
Collection de routes Base de données Objet Doctrine RmllUser
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
24. Les collections de routes d’objets
user:
class: sfDoctrineRouteCollection
options:
model: RmllUser
module: user
prefix_path: /api/users
column: username
with_wildcard_routes: true
actions: [list, create, update, delete, show]
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
25. Les collections de routes d’objets
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
26. Support des formats de sortie
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
27. Support des formats de sortie
❖ Par défaut, symfony supporte le format HTML
❖ Le paramètre « sf_format » définit le format de sortie
❖ Symfony se charge d’envoyer les bons en-têtes en fonction de l’extension
user:
class: sfDoctrineRouteCollection
options:
model: RmllUser
module: user
prefix_path: /api/users
column: username
with_wildcard_routes: true
actions: [list, create, update, delete, show]
requirements: { sf_format: (?:html|xml|json) }
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
34. Sortie HTML
Sortie XML
Sortie JSON
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
35. Cache des résultats
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
36. Cache des résultats
❖ Symfony dispose nativement d’un cache HTML des pages
❖ Chaque sortie générée peut être mise en cache sur le serveur
❖ La durée de vie du cache de chaque page est configurable
❖ Le cache est par défaut stocké sur le système de fichier (sfFileCache)
❖ Symfony offre la possibilité de choisir où stocker le cache :
❖ Fichiers (sfFileCache)
❖ SQLite (sfSQLiteCache)
❖ XCache (sfXCacheCache)
❖ MemCache (sfMemCacheCache)
❖ APC... (sfAPCCache)
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
38. Avant la mise en cache
336 ms
Après la mise en cache
50 ms
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
39. Tests Fonctionnels
de l’API
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
40. Simuler des requêtes GET
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new RmllTestFunctional(new sfBrowser());
$browser->loadFixtures();
$browser->
get('/api/users/hhamon.xml')->
with('request')->begin()->
isFormat('xml')->
isParameter('module', 'user')->
isParameter('action', 'show')->
end()->
with('response')->begin()->
isStatusCode(200)->
isValid()->
end();
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
41. Simuler des requêtes GET
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new RmllTestFunctional(new sfBrowser());
$browser->loadFixtures();
$browser->
get('/api/users/hhamon.xml')-> GET sur le fichier XML
with('request')->begin()->
isFormat('xml')->
isParameter('module', 'user')->
isParameter('action', 'show')->
end()->
with('response')->begin()->
isStatusCode(200)->
isValid()->
end();
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
42. Simuler des requêtes GET
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new RmllTestFunctional(new sfBrowser());
$browser->loadFixtures();
$browser->
get('/api/users/hhamon.xml')-> GET sur le fichier XML
with('request')->begin()->
isFormat('xml')->
isParameter('module', 'user')-> Vérification de la requête
isParameter('action', 'show')->
end()->
with('response')->begin()->
isStatusCode(200)->
isValid()->
end();
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
43. Simuler des requêtes GET
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new RmllTestFunctional(new sfBrowser());
$browser->loadFixtures();
$browser->
get('/api/users/hhamon.xml')-> GET sur le fichier XML
with('request')->begin()->
isFormat('xml')->
isParameter('module', 'user')-> Vérification de la requête
isParameter('action', 'show')->
end()->
with('response')->begin()->
isStatusCode(200)-> Vérification de la réponse
isValid()->
end();
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
44. Simuler des requêtes GET
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
47. $user = array(
'username' => 'pmartin',
'password' => 'something',
'first_name' => 'Paul', Test de la création avec des
'last_name' => 'Martin' paramètres manquants
);
$user = getUser(array('birthdate' => ''));
$browser->
post('/api/users', array('rmll_user' => $user))->
with('response')->isStatusCode(400);
$browser->
post('/api/users', array('rmll_user' => getUser()))->
with('response')->begin()->
isStatusCode(201)->
isRedirected()->
end()->
followRedirect()
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
48. $user = array(
'username' => 'pmartin',
'password' => 'something',
'first_name' => 'Paul', Test de la création avec des
'last_name' => 'Martin' paramètres manquants
);
$user = getUser(array('birthdate' => ''));
$browser->
post('/api/users', array('rmll_user' => $user))->
with('response')->isStatusCode(400);
$browser->
post('/api/users', array('rmll_user' => getUser()))->
with('response')->begin()->
isStatusCode(201)->
isRedirected()->
end()->
followRedirect()
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
49. $user = array(
'username' => 'pmartin',
'password' => 'something',
'first_name' => 'Paul', Test de la création avec des
'last_name' => 'Martin' paramètres manquants
);
$user = getUser(array('birthdate' => ''));
$browser->
post('/api/users', array('rmll_user' => $user))->
with('response')->isStatusCode(400);
$browser->
post('/api/users', array('rmll_user' => getUser()))->
with('response')->begin()->
isStatusCode(201)->
isRedirected()->
end()->
followRedirect() Test de la création avec des
paramètres valides
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
50. Simuler des requêtes POST
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
51. Simuler des requêtes PUT
$user = getUser(array('first_name' => 'Toto'));
$browser->
call('/api/users/pmartin', 'put', array('rmll_user' => $user))->
with('response')->isStatusCode(200)
;
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
52. Simuler des requêtes PUT
$user = getUser(array('first_name' => 'Toto'));
$browser->
call('/api/users/pmartin', 'put', array('rmll_user' => $user))->
with('response')->isStatusCode(200)
;
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
53. Simuler des requêtes DELETE
$browser->
call('/api/users/pmartin', 'delete')->
with('response')->isStatusCode(200);
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
54. Simuler des requêtes DELETE
$browser->
call('/api/users/pmartin', 'delete')->
with('response')->isStatusCode(200);
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
56. Introduction à SOAP
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
57. Qu’est-ce que SOAP ?
❖ « Simple Object Access Protocol »
❖ SOAP est un protocole standard (http://www.w3.org/TR/soap/)
❖ Appel de procédure à distance reposant sur un standard XML
❖ SOAP permet d’invoquer des méthodes sur un objet distant
❖ La réponse est servie au client SOAP sous forme d’une réponse SOAP XML
❖ Transport des requêtes et réponses SOAP avec le protocole HTTP
❖ Les requêtes et réponses SOAP sont des chaînes XML
❖ Les données sont traitées sur le serveur puis converties en XML
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
58. Avantages et Inconvénients
❖ Avantages : ❖ Inconvénients :
✤ Standard éprouvé ✤ Lourd et lent
✤ Indépendant de la plateforme ✤ Verbosité du XML
✤ Indépendant du langage ✤ Difficile à tester et à cacher
✤ Extensible
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
59. Fonctionnement de SOAP
http://domain.com/service?wsdl
http://domain.com/service
SOAP Client
SOAP Serveur
$service = new FooService();
$response = $s->calledMethod($param1, $param2);
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
60. Exposer des services SOAP
avec symfony et Zend
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
61. class ProjectConfiguration extends sfProjectConfiguration
{
static protected $zendLoaded = false;
public function setup()
{
$this->enablePlugins('sfDoctrinePlugin');
self::registerZend();
}
static public function registerZend()
{
if (self::$zendLoaded) {
return;
}
set_include_path(
sfConfig::get('sf_lib_dir').'/vendor'.PATH_SEPARATOR.get_include_path()
);
require_once sfConfig::get('sf_lib_dir').'/vendor/Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
self::$zendLoaded = true;
}
}
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
62. class ProjectConfiguration extends sfProjectConfiguration
{
static protected $zendLoaded = false;
Framework Zend dans
public function setup()
lib/vendor/Zend
{
$this->enablePlugins('sfDoctrinePlugin');
self::registerZend();
}
static public function registerZend()
{
if (self::$zendLoaded) {
return;
}
set_include_path(
sfConfig::get('sf_lib_dir').'/vendor'.PATH_SEPARATOR.get_include_path()
);
require_once sfConfig::get('sf_lib_dir').'/vendor/Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
self::$zendLoaded = true;
}
}
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
63. class ProjectConfiguration extends sfProjectConfiguration
{
static protected $zendLoaded = false;
Framework Zend dans
public function setup()
lib/vendor/Zend
{
$this->enablePlugins('sfDoctrinePlugin');
self::registerZend();
}
static public function registerZend()
Initialisation de
{
if (self::$zendLoaded) { l’autoloader de Zend
return;
}
set_include_path(
sfConfig::get('sf_lib_dir').'/vendor'.PATH_SEPARATOR.get_include_path()
);
require_once sfConfig::get('sf_lib_dir').'/vendor/Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
self::$zendLoaded = true;
}
}
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
64. Création d’un module et d’une route
❖ Création d’un nouveau module converter
$ php symfony generate:module api converter
❖ Création d’une nouvelle route converter_service dans routing.yml
converter_service:
url: /converter/service
param: { module: converter, action: index }
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
65. class TemperatureConverterService
{
/**
* Converts a Celsius temperature into a Fahrenheit temperature.
*
* @param float $value The value to convert
* @return float
*/
public function convertCelsiusToFahrenheit($value)
{
return 1.8 * $value + 32;
}
/**
* Converts a Fahrenheit temperature into a Celsius temperature.
*
* @param float $value The value to convert
* @return float
*/
public function convertFahrenheitToCelsius($value)
{
return (5/9) * $value - 160/9;
}
} PHPDoc importante
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
66. Dévoiler le WSDL
public function executeWsdl(sfWebRequest $request)
{
try
{
$wsdl = new Zend_Soap_AutoDiscover();
$wsdl->setClass('TemperatureConverterService');
$wsdl->handle();
}
catch (Exception $e)
{
$this->logMessage($e->getMessage());
}
return sfView::NONE;
}
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
67. Dévoiler le WSDL
public function executeWsdl(sfWebRequest $request)
{
try
{
$wsdl = new Zend_Soap_AutoDiscover();
$wsdl->setClass('TemperatureConverterService');
$wsdl->handle();
}
catch (Exception $e)
{
$this->logMessage($e->getMessage());
}
return sfView::NONE; Zend génère le WSDL par
} introspection de la PHPDoc
de la classe du service
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
69. Implémenter la passerelle du service
public function executeIndex(sfWebRequest $request)
{
$this->forwardIf(null !== $request->getParameter('wsdl'), 'converter', 'wsdl');
try
{
$wsdl = $this->generateUrl('converter_service', array(), true).'?wsdl';
$server = new Zend_Soap_Server($wsdl);
$server->setClass('TemperatureConverterService');
$server->setReturnResponse(true);
$this->renderText($server->handle());
}
catch (Exception $e)
{
$this->logMessage($e->getMessage());
}
return sfView::NONE;
}
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
70. Consommer le service SOAP
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
71. Consommer le service SOAP
try
{
$client = new Zend_Soap_Client(
'http://api.domain.com/converter/service?wsdl'
);
$celsiusToFahrenheit = $client->convertCelsiusToFahrenheit(30.50);
$fahrenheitToCelsius = $client->convertFahrenheitToCelsius(72.30);
}
catch (SoapFault $e)
{
exit($e->getMessage());
}
echo $celsiusToFahrenheit;
echo $fahrenheitToCelsius;
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
72. Tester le service SOAP
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010
73. Tester le service SOAP
❖ Tester un service SOAP avec PHP est assez compliqué !
❖ La requête et la réponse doivent être testées
❖ Les réponses doivent être simulées (mock)
❖ Zend_Soap a l’avantage d’être déjà testé par Zend
❖ Le fonctionnement de symfony est déjà testé également
❖ A tester unitairement : la classe TemperatureConverterService
Sensio Labs Workshop www.symfony-project.org trainings.sensiolabs.com
mardi 6 juillet 2010