introduction api rest symfony2

14
Introduction API REST avec Symfony2 21/06/2022 Make with by Studeal 1

Upload: quentin-dequippe

Post on 17-Feb-2017

540 views

Category:

Internet


6 download

TRANSCRIPT

Page 1: Introduction API REST Symfony2

01/05/2023 Make with ♥ by Studeal 1

Introduction API RESTavec Symfony2

Page 2: Introduction API REST Symfony2

01/05/2023 2

whoami

Make with ♥ by Studeal

@DequippeQuentinCo-fondateur Studeal

CTO

Make student life easy

Page 3: Introduction API REST Symfony2

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. »

Page 4: Introduction API REST Symfony2

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

Page 5: Introduction API REST Symfony2

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

Page 6: Introduction API REST Symfony2

01/05/2023 Make with ♥ by Studeal 6

REST API / The Basics

API « Application

Programming Interface »

REST « REpresentational State

Transfer »

RESTful API

Page 7: Introduction API REST Symfony2

01/05/2023 Make with ♥ by Studeal 7

REST & Symfony2Basics ToDo app

Page 8: Introduction API REST Symfony2

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

Page 9: Introduction API REST Symfony2

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

Page 10: Introduction API REST Symfony2

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

Page 11: Introduction API REST Symfony2

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

Page 12: Introduction API REST Symfony2

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

Page 13: Introduction API REST Symfony2

01/05/2023 Make with ♥ by Studeal 13

Live Code …