Overview

Namespaces

  • api
  • config
  • database
  • PHP
  • Slim
    • Exception
    • Http
    • Middleware
  • utiliy

Classes

  • ContentTypes
  • Flash
  • MethodOverride
  • PrettyExceptions
  • SessionCookie
  • Overview
  • Namespace
  • Class
  • Tree

Class ContentTypes

Content Types

This is middleware for a Slim application that intercepts the HTTP request body and parses it into the appropriate PHP data structure if possible; else it returns the HTTP request body unchanged. This is particularly useful for preparing the HTTP request body for an XML or JSON API.

Slim\Middleware
Extended by Slim\Middleware\ContentTypes
Namespace: Slim\Middleware
Package: Slim
Author: Josh Lockhart
Since: 1.6.0
Located at thirdparty/Slim/Middleware/ContentTypes.php
Methods summary
public
# __construct( array $settings = array() )

Constructor

Constructor

Parameters

$settings
array
$settings
public
# call( )

Call

Call

protected mixed
# parse( string $input, string $contentType )

Parse input

Parse input

This method will attempt to parse the request body based on its content type if available.

Parameters

$input
string
$input
$contentType
string
$contentType

Returns

mixed
protected array|string
# parseJson( string $input )

Parse JSON

Parse JSON

This method converts the raw JSON input into an associative array.

Parameters

$input
string
$input

Returns

array|string
protected SimpleXMLElement|string
# parseXml( string $input )

Parse XML

Parse XML

This method creates a SimpleXMLElement based upon the XML input. If the SimpleXML extension is not available, the raw input will be returned unchanged.

Parameters

$input
string
$input

Returns

SimpleXMLElement|string
protected array
# parseCsv( string $input )

Parse CSV

Parse CSV

This method parses CSV content into a numeric array containing an array of data for each CSV line.

Parameters

$input
string
$input

Returns

array
Methods inherited from Slim\Middleware
getApplication(), getNextMiddleware(), setApplication(), setNextMiddleware()
Properties summary
protected array $contentTypes
#
Properties inherited from Slim\Middleware
$app, $next
GeoApi API documentation generated by ApiGen 2.8.0