introduction api rest symfony2
Post on 17-Feb-2017
535 Views
Preview:
TRANSCRIPT
01/05/2023 Make with ♥ by Studeal 1
Introduction API RESTavec Symfony2
01/05/2023 2
whoami
Make with ♥ by Studeal
@DequippeQuentinCo-fondateur Studeal
CTO
Make student life easy
01/05/2023 Make with ♥ by Studeal 3
What is Symfony?
« Symfony is a set of PHP Components, a Web Application framework, a
Philosophy, and a Community — all working together in harmony. »
01/05/2023 Make with ♥ by Studeal 4
What is Symfony? / Inside & Bundles
« Symfony is also an HTTP full-stack web framework made of
bundles and third party libraries »
Dependency InjectionLocale
EventDispatcherConsole
Routing
HttpKernel
Yaml
FOSUserBundle
FOSRestBundle
KnpPaginatorBundle
01/05/2023 Make with ♥ by Studeal 5
What is Symfony? / The Power
Oui oui vous ne rêvez pas …
+2,500Bundles
+300,000
Symfony developers
+5,000,000
Monthly downloads
+2,000Project contributors
Official Documentation
01/05/2023 Make with ♥ by Studeal 6
REST API / The Basics
API « Application
Programming Interface »
REST « REpresentational State
Transfer »
RESTful API
01/05/2023 Make with ♥ by Studeal 7
REST & Symfony2Basics ToDo app
01/05/2023 Make with ♥ by Studeal 8
REST & Symfony2 / Structure• MVC
• API REST HTTP with Symfony2 (RESTful API)
• ToDo application: list, create, update, delete notes
• Relation avec base de données
• JSON
01/05/2023 Make with ♥ by Studeal 9
REST & Symfony2 / Bundles (1)
• View (JSON)• REST Routes (GET /notes, POST /notes…)• Custom Headers (ex: authentification, format ...)• RESTful decoding HTTP request• HTTP codes
https://github.com/FriendsOfSymfony/FOSRestBundleFOSRestBundle
01/05/2023 Make with ♥ by Studeal 10
REST & Symfony2 / Bundles (2)
• Serialization (Deserialization)• Security• Custom exposition
https://github.com/schmittjoh/JMSSerializerBundle+ https://github.com/schmittjoh/JMSSecurityExtraBundle
JMSSerializerBundle + JMSSecurityExtraBundle
01/05/2023 Make with ♥ by Studeal 11
REST & Symfony2 / Bundles (3)
• API Documentation• Sandbox• Tests• CORS (Cross-Origin Resource Sharing)
https://github.com/nelmio/NelmioApiDocBundle+ https://github.com/nelmio/NelmioCorsBundle
NelmioApiDocBundle + NelmioCorsBundle
01/05/2023 Make with ♥ by Studeal 12
REST & Symfony2 / Bundles (summary)
• https://github.com/FriendsOfSymfony/FOSRestBundle
• https://github.com/schmittjoh/JMSSerializerBundle
• https://github.com/nelmio/NelmioApiDocBundle
• #Bonus: https://github.com/nelmio/NelmioCorsBundle
• #Bonus: https://github.com/schmittjoh/JMSSecurityExtraBundle
01/05/2023 Make with ♥ by Studeal 13
Live Code …
01/05/2023 Make with ♥ by Studeal 14
Sources
• https://en.wikipedia.org/wiki/Representational_state_transfer• https://speakerdeck.com/hhamon• http://williamdurand.fr/2012/08/02/rest-apis-with-symfo
ny2-the-right-way/• http://
afsy.fr/avent/2013/06-best-practices-pour-vos-apis-rest-http-avec-symfony2• https://
en.wikipedia.org/wiki/Application_programming_interface
top related