malfasih / slim3-json-parser
Parsing JSON response for REST API with CORS management
v1.0.1
2018-09-19 18:55 UTC
Requires
- php: >=5.5
This package is not auto-updated.
Last update: 2024-05-12 03:38:28 UTC
README
Parsing JSON response for Slim v3 REST API with CORS management - https://projects.alal.io
Installation
Before we get started, please make sure that you have installed Slim 3 Framework. I was using slim-born from HavenShen for developing this module.
$ composer require malfasih/slim3-json-parser
or
composer.json
"require": { "malfasih/slim3-json-parser": "@dev" }
Registering Component
<?php require __DIR__ . '/../vendor/autoload.php'; $app = new \Slim\App(); $container = $app->getContainer(); $container['json'] = function($container) { return new \Malfasih\Slim\JsonParser(); };
Testing
Just with a single line of code, and it actually works.
<?php public function getUserData($request, $response) { return $this->json->print($response, true, 'OK'); }