happyr / api-bundle
Api stuff for most Happyr projects
Installs: 24 336
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.0
- league/fractal: ^0.16.0
- psr/cache: ^1.0
- symfony/framework-bundle: ^3.3 || ^4.0
- symfony/http-foundation: ^3.3 || ^4.0
- symfony/security-bundle: ^3.3 || ^4.0
- symfony/validator: ^3.3 || ^4.0
Requires (Dev)
README
To Install
Run the following in your project root, assuming you have composer set up for your project
composer require happyr/api-bundle
Add the bundle to app/AppKernel.php
$bundles = [ // ... new Happyr\ApiBundle\HappyrApiBundle(), ];
Security
Wsse is built in and can be enabled - disabled by default.
To enable and configure it, in config.yml add
happyr_api: wsse: user_provider: "security.user.provider.concrete.in_memory" cache_service: "cache.provider.redis" lifetime: 300 debug: false # Set to true to disable WSSE completely. You will always be authenticated.
And in security.yml configure your provider where you store users to something like this
security: providers: in_memory: memory: users: username: password: password roles: ['ROLE_API_USER']
And under firewalls in security.yml, add a new firewall like so
security: firewalls: main: pattern: ^/api/ stateless: true wsse: true
Exception listener
Exception listener is enabled by default. It will catch uncaught exceptions and return formatted json response.
Here is an example configuration:
happyr_api: exception_listener: enabled: false # disables response listener path_prefix: '/api/' # path prefix to enable listener on. By default its enabled for any path