SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Slim
SLIM IS A PHP MICRO FRAMEWORK THAT HELPS YOU QUICKLY WRITE SIMPLE YET POWERFUL REST API
PRAMOD KUMAR RAGHAV
REST Vs SOAP
REST (Representational State Transfer)
REST Vs SOAP
REST (Representational State Transfer)
SOAP (Simple Object Access Protocol)
REST Vs SOAP
REST (Representational State Transfer)
SOAP (Simple Object Access Protocol)
RESTs is good when you are exposing a public API over the internet to handle CRUD
operations on data. REST is focused on accessing named resources through a single consistent
interface.
SOAP brings it’s own protocol and focuses on exposing pieces of application logic (not data)
as services.
REST Vs SOAP Cont…
REST permits many different data formats like (JSON, XML, CSV,RSS …)
SOAP only permits XML data formats.
REST allows better support for browser clients due to it’s support for JSON.
REST reads can be cached, SOAP based reads cannot be cached.
SOAP support ACID Transactions over a service while REST isn’t ACID compliant.
REST Vs SOAP Cont…
REST is limited by HTTP itself which can’t provide two-phase commit across distributed
transactional resources, but SOAP can.
OVERVIEW
Slim is a dispatcher that receives an HTTP request, invokes an appropriate
callback routine, and returns an HTTP response. That’s it.
Installation
System Requirements
o Web server with URL rewriting
o PHP 5.5 or newer
How to Install Slim
Install Slim with Composer and execute the below command under your project
root directory.
composer require slim/slim "^3.0"
This command downloads the Slim Framework and its third-party dependencies
into your project’s vendor/ directory.
Application
The Application, (or SlimApp) is the entry point to your Slim application and
is used to register the route that link to your callbacks or controllers.
The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
Application Configuration
The Application accepts just one argument. This can be either
a Container instance or an array to configure the default container that is
created automatically.
The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
Request & Response
Slim app’s routes and middleware are given a PSR 7 request object that represents the
current HTTP request received by your web server.
The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
 The PSR 7 request object is injected into your Slim application routes as the first argument
to the route callback.
 The PSR 7 response object is injected into your Slim application routes as the second
argument to the route callback.
Request & Response
The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
The Request Headers
Every HTTP request has headers.
These are metadata that describe the HTTP request but are not visible in the request’s
body.
The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
The Request Headers ….
Get All Headers: You can fetch all HTTP request headers as an associative array.
The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
The Request Headers ….
Get One Header: You can get a single header’s value(s) with the PSR 7 Request object’s
getHeader($name) method. This returns an array of values for the given header name.
Remember, a single HTTP header may have more than one value!
The Request Body
Following methods have request body
POST, PUT, PATCH
Slim can parse JSON, XML, and URL-encoded data out of the box.
 JSON requests are converted into associative arrays with json_decode($input, true).
 XML requests are converted into a SimpleXMLElement with
simplexml_load_string($input).
 URL-encoded requests are converted into a PHP array with parse_str($input).
The Request Body
You can get the HTTP request body StreamInterface instance with the PSR 7 Request
object’s getBody() method. The getBody() method is preferable if the incoming HTTP
request size is unknown or too large for available memory.
 JSON requests are converted into associative arrays with json_decode($input, true).
 XML requests are converted into a SimpleXMLElement with
simplexml_load_string($input).
 URL-encoded requests are converted into a PHP array with parse_str($input).
Response Status
Every HTTP response has a numeric status code. The status code identifies the type of
HTTP response to be returned to the client.
You can copy a PSR 7 Response object and assign a new status code like this:
Response Headers
Every HTTP response has headers. These are metadata that describe the HTTP response
but are not visible in the response’s body.
Response Status
Set Header: You can set a header value with the PSR 7 Response object’s withHeader($name,
$value) method.
Append Header: You can append a header value with the PSR 7 Response object’s
withAddedHeader($name, $value) method.
Remove Header: You can remove a header with the Response object’s withoutHeader($name) method.
Returning JSON
Slim’s Response object has a custom method withJson($data, $status, $encodingOptions) to
help simplify the process of returning JSON data.
JSON data can be returned with a default 200 HTTP status code. But we can also return JSON data with
a custom HTTP status code.

Más contenido relacionado

La actualidad más candente

REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101Samantha Geitz
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkBo-Yi Wu
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsNeil Crookes
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Caldera Labs
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Ryan Szrama
 
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India 2015 - Rest with Java (jax rs) and jerseyEclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India 2015 - Rest with Java (jax rs) and jerseyEclipse Day India
 
Introduction to plugin development
Introduction to plugin developmentIntroduction to plugin development
Introduction to plugin developmentCaldera Labs
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajaxs_pradeep
 
CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsanthony_putignano
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroChristopher Pecoraro
 
Spray - Build RESTfull services in scala
Spray - Build RESTfull services in scalaSpray - Build RESTfull services in scala
Spray - Build RESTfull services in scalaSandeep Purohit
 
Web service with Laravel
Web service with LaravelWeb service with Laravel
Web service with LaravelAbuzer Firdousi
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockCaldera Labs
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVCIndicThreads
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravelConfiz
 

La actualidad más candente (20)

REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
 
Psr-7
Psr-7Psr-7
Psr-7
 
Designing CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIsDesigning CakePHP plugins for consuming APIs
Designing CakePHP plugins for consuming APIs
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
 
Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7Making the Most of Modern PHP in Drupal 7
Making the Most of Modern PHP in Drupal 7
 
CakePHP REST Plugin
CakePHP REST PluginCakePHP REST Plugin
CakePHP REST Plugin
 
Day01 api
Day01   apiDay01   api
Day01 api
 
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India 2015 - Rest with Java (jax rs) and jerseyEclipse Day India 2015 - Rest with Java (jax rs) and jersey
Eclipse Day India 2015 - Rest with Java (jax rs) and jersey
 
Introduction to plugin development
Introduction to plugin developmentIntroduction to plugin development
Introduction to plugin development
 
Javascript laravel's friend
Javascript laravel's friendJavascript laravel's friend
Javascript laravel's friend
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajax
 
CakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIsCakeFest 2013 - A-Z REST APIs
CakeFest 2013 - A-Z REST APIs
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Spray - Build RESTfull services in scala
Spray - Build RESTfull services in scalaSpray - Build RESTfull services in scala
Spray - Build RESTfull services in scala
 
Web service with Laravel
Web service with LaravelWeb service with Laravel
Web service with Laravel
 
Extending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravel
 

Similar a Slim Framework

KaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: IntroductionKaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: IntroductionKate_RESTful
 
The introduction of RESTful
The introduction of RESTful The introduction of RESTful
The introduction of RESTful Jon Chen
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Charlin Agramonte
 
Lunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's GuideLunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's GuideLunacloud
 
6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring FrameworkArcadian Learning
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling ResolutionDEEPAK KHETAWAT
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and ODataAnil Allewar
 
The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleEmiliano Pecis
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!Evan Mullins
 
Api wiki · git hub
Api wiki · git hubApi wiki · git hub
Api wiki · git hubFerry Irawan
 

Similar a Slim Framework (20)

Rest web service
Rest web serviceRest web service
Rest web service
 
Salesforce Integration
Salesforce IntegrationSalesforce Integration
Salesforce Integration
 
API Basics
API BasicsAPI Basics
API Basics
 
KaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: IntroductionKaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: Introduction
 
The introduction of RESTful
The introduction of RESTful The introduction of RESTful
The introduction of RESTful
 
Switch to Backend 2023
Switch to Backend 2023Switch to Backend 2023
Switch to Backend 2023
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5
 
Lunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's GuideLunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's Guide
 
6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework
 
Asp.net web api
Asp.net web apiAsp.net web api
Asp.net web api
 
Apitesting.pptx
Apitesting.pptxApitesting.pptx
Apitesting.pptx
 
Salesforce REST API
Salesforce  REST API Salesforce  REST API
Salesforce REST API
 
SFDC REST API
SFDC REST APISFDC REST API
SFDC REST API
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
JAX-RS 2.0 and OData
JAX-RS 2.0 and ODataJAX-RS 2.0 and OData
JAX-RS 2.0 and OData
 
The RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with Oracle
 
Web Service
Web ServiceWeb Service
Web Service
 
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Raleigh 2016 - WP API, What is it good for? Absolutely Everything!
 
Api wiki · git hub
Api wiki · git hubApi wiki · git hub
Api wiki · git hub
 
SCDJWS 6. REST JAX-P
SCDJWS 6. REST  JAX-PSCDJWS 6. REST  JAX-P
SCDJWS 6. REST JAX-P
 

Último

Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfkalichargn70th171
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingShane Coughlan
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainAbdul Ahad
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITmanoharjgpsolutions
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Copilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotCopilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotEdgard Alejos
 

Último (20)

Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdfPros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
Pros and Cons of Selenium In Automation Testing_ A Comprehensive Assessment.pdf
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full RecordingOpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
OpenChain Education Work Group Monthly Meeting - 2024-04-10 - Full Recording
 
Data modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software DomainData modeling 101 - Basics - Software Domain
Data modeling 101 - Basics - Software Domain
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
Best Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh ITBest Angular 17 Classroom & Online training - Naresh IT
Best Angular 17 Classroom & Online training - Naresh IT
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Copilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform CopilotCopilot para Microsoft 365 y Power Platform Copilot
Copilot para Microsoft 365 y Power Platform Copilot
 

Slim Framework

  • 1. Slim SLIM IS A PHP MICRO FRAMEWORK THAT HELPS YOU QUICKLY WRITE SIMPLE YET POWERFUL REST API PRAMOD KUMAR RAGHAV
  • 2. REST Vs SOAP REST (Representational State Transfer)
  • 3. REST Vs SOAP REST (Representational State Transfer) SOAP (Simple Object Access Protocol)
  • 4. REST Vs SOAP REST (Representational State Transfer) SOAP (Simple Object Access Protocol) RESTs is good when you are exposing a public API over the internet to handle CRUD operations on data. REST is focused on accessing named resources through a single consistent interface. SOAP brings it’s own protocol and focuses on exposing pieces of application logic (not data) as services.
  • 5. REST Vs SOAP Cont… REST permits many different data formats like (JSON, XML, CSV,RSS …) SOAP only permits XML data formats. REST allows better support for browser clients due to it’s support for JSON. REST reads can be cached, SOAP based reads cannot be cached. SOAP support ACID Transactions over a service while REST isn’t ACID compliant.
  • 6. REST Vs SOAP Cont… REST is limited by HTTP itself which can’t provide two-phase commit across distributed transactional resources, but SOAP can.
  • 7. OVERVIEW Slim is a dispatcher that receives an HTTP request, invokes an appropriate callback routine, and returns an HTTP response. That’s it.
  • 8. Installation System Requirements o Web server with URL rewriting o PHP 5.5 or newer How to Install Slim Install Slim with Composer and execute the below command under your project root directory. composer require slim/slim "^3.0" This command downloads the Slim Framework and its third-party dependencies into your project’s vendor/ directory.
  • 9. Application The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers. The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
  • 10. Application Configuration The Application accepts just one argument. This can be either a Container instance or an array to configure the default container that is created automatically. The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
  • 11. Request & Response Slim app’s routes and middleware are given a PSR 7 request object that represents the current HTTP request received by your web server. The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.  The PSR 7 request object is injected into your Slim application routes as the first argument to the route callback.  The PSR 7 response object is injected into your Slim application routes as the second argument to the route callback.
  • 12. Request & Response The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
  • 13. The Request Headers Every HTTP request has headers. These are metadata that describe the HTTP request but are not visible in the request’s body. The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
  • 14. The Request Headers …. Get All Headers: You can fetch all HTTP request headers as an associative array. The Application, (or SlimApp) is the entry point to your Slim application and is used to register the route that link to your callbacks or controllers.
  • 15. The Request Headers …. Get One Header: You can get a single header’s value(s) with the PSR 7 Request object’s getHeader($name) method. This returns an array of values for the given header name. Remember, a single HTTP header may have more than one value!
  • 16. The Request Body Following methods have request body POST, PUT, PATCH Slim can parse JSON, XML, and URL-encoded data out of the box.  JSON requests are converted into associative arrays with json_decode($input, true).  XML requests are converted into a SimpleXMLElement with simplexml_load_string($input).  URL-encoded requests are converted into a PHP array with parse_str($input).
  • 17. The Request Body You can get the HTTP request body StreamInterface instance with the PSR 7 Request object’s getBody() method. The getBody() method is preferable if the incoming HTTP request size is unknown or too large for available memory.  JSON requests are converted into associative arrays with json_decode($input, true).  XML requests are converted into a SimpleXMLElement with simplexml_load_string($input).  URL-encoded requests are converted into a PHP array with parse_str($input).
  • 18. Response Status Every HTTP response has a numeric status code. The status code identifies the type of HTTP response to be returned to the client. You can copy a PSR 7 Response object and assign a new status code like this:
  • 19. Response Headers Every HTTP response has headers. These are metadata that describe the HTTP response but are not visible in the response’s body.
  • 20. Response Status Set Header: You can set a header value with the PSR 7 Response object’s withHeader($name, $value) method. Append Header: You can append a header value with the PSR 7 Response object’s withAddedHeader($name, $value) method. Remove Header: You can remove a header with the Response object’s withoutHeader($name) method.
  • 21. Returning JSON Slim’s Response object has a custom method withJson($data, $status, $encodingOptions) to help simplify the process of returning JSON data. JSON data can be returned with a default 200 HTTP status code. But we can also return JSON data with a custom HTTP status code.