kununu / rest-api-bundle
This is a wrapper for mediamonks/rest-api-bundle adding kununu specific functionality.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 11 760
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 16
Forks: 0
Open Issues: 4
Type:symfony-bundle
Requires
- php: ^7.2
- ext-curl: *
- ext-json: *
- mediamonks/rest-api-bundle: ^3.0
- psr/log: ^1.0
- symfony/config: ^4.0
- symfony/console: ^4.0
- symfony/dependency-injection: ^4.0
- symfony/expression-language: ^4.0
- symfony/http-kernel: ^4.0
- symfony/security-bundle: ^4.0
Requires (Dev)
- jms/serializer-bundle: ~2.4
- matthiasnoback/symfony-dependency-injection-test: ~4.0
- mockery/mockery: ~1.2
- phpunit/phpunit: ^8.0
- symfony/browser-kit: ~4.0
- symfony/phpunit-bridge: ^4.0
- symfony/validator: ^4.0
- symfony/var-dumper: ~4.0
Suggests
- jms/serializer: Use JMS Serializer as a serializer
Conflicts
- dev-master
- 4.1.0
- 4.0.0
- 3.0.0
- 2.5.0
- 2.4.1
- 2.4.0
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.1
- 2.0.0
- 1.0.2
- 1.0.0
- dev-dependabot/composer/jms/serializer-bundle-approx-3.8
- dev-dependabot/composer/symfony/phpunit-bridge-tw-5.2
- dev-dependabot/composer/mediamonks/rest-api-bundle-tw-4.0
- dev-symfony4
- dev-update-jms-serializer
- dev-change-aws-trusted-proxies-subscriber-priority
This package is not auto-updated.
Last update: 2021-02-24 18:18:34 UTC
README
This is a wrapper for mediamonks/rest-api-bundle to support custom Kununu requirements.
Configuration
For all configuration options please follow the original bundle.
Note
Since this is a wrapper of MediaMonks Rest API Bundle, the configuration name stays unchanged: mediamonks_rest_api
Installation
Step 1: Add custom private repositories to composer.json
... "repositories": [ { "type": "vcs", "url": "https://github.com/kununu/symfony-rest-api-bundle.git", "no-api": true }, ],
Step 2: Install the bundle
Open a command console, enter your project directory and execute:
$ composer require kununu/rest-api-bundle:^4.0
For applications that don't use Symfony Flex
Step 2.1: Enable the bundle
// app/ApisKernel.php class ApiKernel extends Kernel { public function registerBundles() { $bundles = [ // ... new Kununu\RestApiBundle\KununuRestApiBundle(), ]; } }
Step 3: Configuration
# config/config.yml ... # MediaMonks Rest API bundle mediamonks_rest_api: serializer: JMS request_matcher: whitelist: [~^/~]
Important note!
Since this requires the Kununu Monolog Bundle be sure to also configure the application name in your configuration:
# config/config.yml ... kununu_monolog: processors: application: APPLICATION_NAME
AWS Trusted Proxies Request Listener
In order to get the Client IP Address properly on services behind the Cloudfront in AWS environment, AwsTrustedProxiesRequestListener.php was added. Listener is disabled by default and must be enabled in the config:
Important note!
If you are requesting the service from an another service, e.g. BFF, you need to set both CLOUDFRONT and AMAZON
in aws_service_list: ['CLOUDFRONT', 'AMAZON']
# config/config.yml # MediaMonks Rest API bundle mediamonks_rest_api: aws_trusted_proxies: enabled: true cache_key: 'aws_trusted_proxies_ip_ranges' # Not required cache_ttl: 43200 # Not required aws_services_list: ['CLOUDFRONT', 'AMAZON'] # Not required
AWS Trusted Proxies - import command
To improve the performance of the AWS Trusted Proxies feature, there is a command available to fetch the Trusted proxies and save them
to the app cache during the container start. You can simply add the command into your bin/run_startup.sh
:
# bin/run_startup.sh cd $(dirname $PWD/$0) php console kununu:import-aws-trusted-proxies
JMS Serializer Context Response
Support for JMS Serializer SerializationContext was added to enable the possibility of using the Serialization groups and versions provided by JMS Serializer.
Usage is simple and requires an usage of a new ContextJsonResponse:
// ApiBundle\Controller\IndexController.php namespace ApiBundle\Controller; use ApiBundle\ExampleEntity; use JMS\Serializer\SerializationContext; use JMS\Serializer\SerializerInterface; use Kununu\RestApiBundle\Response\ContextJsonResponse; class IndexController { public function IndexAction() { $data = [ 'entity' => new ExampleEntity(), ]; return new ContextJsonResponse($data, SerializationContext::create()->setGroups(['Default', 'group1', 'group2'])); } }
Kununu legacy response model
If the service needs to use our legacy response model, you can use KununuLegacyResponseModel included in this bundle.
# config/config.yml # MediaMonks Rest API bundle mediamonks_rest_api: response_model: kununu_legacy
Custom Response Model
You can also use a custom ResponseModel by implementing MediaMonks\RestApi\Model\ResponseModelInterface
// ApiBundle\Model\CustomResponseModel namespace ApiBundle\Model; use MediaMonks\RestApi\Model\ResponseModelInterface; class CustomResponseModel implements ResponseModelInterface { // your code }
Configuration
First, register the Response model as a service
# config/services.yml ... services: app.kununu_response_model: class: ApiBundleModel\Model\ResponseModelClass
Now use the service as an option in bundle config:
# config/config.yml # MediaMonks Rest API bundle mediamonks_rest_api: response_model: app.kununu_response_model