PHP Classes

File: docs/files/ApiTrait.php.txt

Recommend this page to a friend!
  Classes of Natanael Simões   PHP API Framework   docs/files/ApiTrait.php.txt   Download  
File: docs/files/ApiTrait.php.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: PHP API Framework
Handle API requests with annotated classes
Author: By
Last change:
Date: 7 years ago
Size: 412 bytes
 

Contents

Class file image Download
<?php namespace PhpApi; trait ApiTrait { protected $requestMethod; protected $input; public function __construct() { $this->requestMethod = $_SERVER['REQUEST_METHOD']; $this->input = json_decode(file_get_contents('php://input'), true); } public function response($obj) { header('Content-Type: application/json'); echo json_encode($obj); } }