starx / bernard-silex
Silex service provider for Bernard
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 3
pkg:composer/starx/bernard-silex
Requires
- php: >=5.3.3
- bernard/bernard: >=0.12,<0.13
Requires (Dev)
- silex/silex: ~1.0
This package is not auto-updated.
Last update: 2025-10-17 07:11:27 UTC
README
Getting Started
Add the requirement to your composer.json file and register it with you Application.
{
"require" : {
"bernard/silex" : "~0.4@dev"
}
}
<?php $app = new Silex\Application; $app->register(new Bernard\Silex\BernardServiceProvider, array( 'bernard.options' => array( 'driver' => 'doctrine', // or redis, predis, sqs, iron_mq 'serializer' => 'symfony', // or jms or simple ), ));
After that you have to make a decision about what driver and what kind of Serializer you want to use.
The following serializers are supported:
- Simple. No dependencies and it is the default.
- JMS Serializer. Requires a service with id
jms_serializerandjms_serializer.builderis present. - Symfony Serializer. Requires
SerializerServiceProvideris registered before this provider.
The following drivers are supported:
- Doctrine DBAL requires
DoctrineServiceProviderwhere it try and use abernardconnection. - Predis requires https://github.com/nrk/PredisServiceProvider and a
predisservice. If you use the multi service provider, you should overwritebernard.predis_driverand do a custom service. - Redis extension. Requires http://pecl.php.net/package/redis to be installed and a
redisservice. - Amazon SQS requires AWS SDK PHP version 2 or creater and https://github.com/aws/aws-sdk-php-silex.
- Iron.MQ requires
iron-io/iron_mqpackage and airon_mqservice.
Registering with the ServiceResolver
The ServiceResolver enabled supports service ids. This means they are lazy loaded when they are needed instead of when they are registering.
Register bernard.services with an array of MessageName => ServiceId like so:
<?php $app['bernard.receivers'] = array( 'ImportUsers' => 'users_worker', );
Console
If there is a service named console the consume command will be automatically registred. For advanced
usecases see the official documentation on Bernard.