flyingcolours / common-bundle
Symfony Bundle with commonly used code
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 618
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Type:symfony-bundle
Requires
- php: >=7.1
- sensio/framework-extra-bundle: ~3|~4|~5
- symfony/framework-bundle: ~2.3|~3|~4
- symfony/serializer: ~2.3|~3|~4
- symfony/twig-bundle: ~4
- willdurand/negotiation: ^2.2
Requires (Dev)
- leanphp/phpspec-code-coverage: ^4.0
- phpspec/phpspec: ^4.3
- psr/simple-cache: ^1.0
- satooshi/php-coveralls: ^2.0
- dev-master
- 0.2.0
- 0.1.10
- 0.1.9
- 0.1.8
- 0.1.7
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1
- dev-develop
- dev-revert-5-feature/in-memory-cache
- dev-feature/in-memory-cache
- dev-feature/api_list_filtering_fields
- dev-feature/negotiation-update-v2.3
- dev-release/0.1.4
- dev-bugfix/array-push-additional-acl-headers
- dev-feature/allow-location-headers-in-201-response
This package is auto-updated.
Last update: 2023-07-29 01:36:17 UTC
README
Common Symfony classes used throughout the projects
Installation
composer require flyingcolours/common-bundle "^0.2.0"
This version works with Symfony 4.3, for previous version please check previous versions.
Components
Content Negotiation and Template Resolver Listener
Symfony Event Listener which works out right response content type based on "Accept" header.
# app/config/services.yml parameters: priorities: [ 'application/json', 'text/html' ] services: listener.template.resolver: class: FlyingColours\CommonBundle\Listener\TemplateResolverListener arguments: [ "@sensio_framework_extra.view.guesser" ] tags: - { name: kernel.event_listener, event: kernel.controller, method: onKernelController } listener.content.negotiation: class: FlyingColours\CommonBundle\Listener\ContentNegotiationListener arguments: $priorities: "%priorities%" tags: - { name: kernel.event_listener, event: kernel.view, method: onKernelView }
Persistent Memcached
If you ever experienced problem described here then you want to use this class instead of default Memcached.
# app/config/services.yml services: memcached: class: FlyingColours\CommonBundle\Service\PersistentMemcached arguments: persistent_id: "%session_prefix%" calls: - [ addServer, [ "%memcached_host%", "%memcached_port%" ]] session.handler.memcached: class: Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler arguments: [ "@memcached", { prefix: "%session_prefix%", expiretime: "%session_expire%" }]
CORS Listener
See this page for details
# app/config/services.yml services: listener.cors.headers: class: FlyingColours\CommonBundle\Listener\CorsHeadersListener tags: - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse }
Also if you want to implement quick OPTIONS handler without creating special action or controller,
you can add additional tag for kernel.request
event.
# app/config/services.yml services: listener.cors.headers: class: FlyingColours\CommonBundle\Listener\CorsHeadersListener tags: - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse } - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 33 }
To use in memory cache just use it in same way as memcached implementation:
services:
cache.in_memory:
class: FlyingColours\CommonBundle\Service\InMemoryCache