Package Data | |
---|---|
Maintainer Username: | SzymonDukla |
Maintainer Contact: | hello@szymondukla.com (Szymon Dukla) |
Package Create Date: | 2019-02-26 |
Package Last Update: | 2019-02-27 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2021-04-06 15:26:39 |
Package Statistics | |
---|---|
Total Downloads: | 18 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Compatible with Slim Framework 3.0, 3.1
Use Composer to install the package:
composer require szymondukla/slim3-json-transformer
Open up your settings file and add an entry for your mappings:
return [
'settings' => [
// JSON-API settings
'json-api' => [
'mappings' => [
Mappings\ContactMapping::class,
Mappings\OwnerMapping::class
]
]
]
];
Open up your dependencies file and add an entry for the JsonApiSerializer, using the mappings you defined in the settings.
$container[SzymonDukla\Slim3\JsonApi\JsonApiSerializer::class] = function (ContainerInterface $c) {
$mappings = $c->get('settings')['json-api']['mappings'];
$mapper = new SzymonDukla\Slim3\JsonApi\Mapper\Mapper($mappings);
$mappingHelper = new SzymonDukla\Slim3\JsonApi\Mapper\MappingHelper();
$parsedRoutes = $mappingHelper->parseRoutes($mapper);
$transformer = new AmaranthCloud\Api\JsonApi\JsonApiTransformer($parsedRoutes);
return new SzymonDukla\Slim3\JsonApi\JsonApiSerializer($transformer);
};