This bundle allows you to set up a life page on your site. A certain number of predefines checkers are available and automatically configured depending on your actual project configuration.
Use the package manager composer to install the extension.
composer require umanit/life-page-bundle
Load the bundle into your Symfony project.
<?php
# config/bundles.php
return [
// ...
Umanit\LifePageBundle\UmanitLifePageBundle::class => ['all' => true],
];
Import the route file:
umanit_life_page:
resource: '@UmanitLifePageBundle/Resources/config/routing.yaml'
Or, if your prefer customize it, adapt the default declaration:
umanit_life_page:
path: /_life/{type}
controller: umanit_life_page.controller_life_page
methods: [GET]
requirements:
type: '[a-zAZ0-9]+'
defaults:
type: all
That’s it! Your life page should now be accessible at the path /_life
and some checks already done if your
configuration meets the requirements.
The following checkers are available. Each of them are automatically configured if possible, but you can manually use them if needed.
DoctrineChecker
PommChecker
FosElasticaChecker
SmtpMailerChecker
SwiftmailerChecker
MessengerChecker
Using an entity manager, tries to connect to the database.
If the service doctrine.orm.default_entity_manager
exists, a checker is added using it.
Using Pomm, retrieves the default session and tries to get client encoding.
If the service pomm.default_session
exists, a checker is added using it.
Using a client, tries to get the server version.
If the service fos_elastica.client.default
exists, a checker is added using it.
Using a mailer transport, and only if it’s an instance of SmtpTransport
, tries to execute a NOOP
command on the SMTP
server.
If the service mailer.default_transport
exists, a checker is added using it.
SmtpTransport
, the checker will be ignored.
Using SwiftMailer instance, tries to ping the transport.
If the service swiftmailer.mailer.default
exists, a checker is added using it.
Using a messenger transport, and only if it’s an instance of MessageCountAwareInterface
, tries to count available
messages.
For each service tagged with messenger.receiver
, a checker will be added.
MessageCountAwareInterface
, the checker will be ignored.
Create a service which extends the CheckerInterface
and tag it with umanit_life_page.service_checker
. Your checker
should now be displayed on the life page.
The method getName
is used to name the checker on the page while the check
method is used to determine the status to
display. If it’s true
then OK
is shown, if it’s false
then KO
is shown and if it’s null
the checker is
ignored.
By adding your own service checker service, you can check only specific services if needed. You need to follow this steps:
- Tag some of your services checker with a custom tag ;
- declare a new service using the class
Umanit\LifePageBundle\Checker\ServiceChecker
- The service must use a
tagged_iterator
as argument, using your custom tag from the previous step. - The service must be tag with
umanit_life_page.service_checker_collection
and have a uniquetype
value.
- The service must use a
Example:
<service id="umanit_life_page.critical_services_checker" class="Umanit\LifePageBundle\Checker\ServiceChecker">
<argument type="tagged_iterator" tag="umanit_life_page.critical_service_checker" />
<tag name="umanit_life_page.service_checker_collection" type="critical" />
</service>
Once it’s done you can access to the check using the path /_life/{type}
, so with our example /_life/critical
.
The bundle is already providing the critical
type and all of it’s checker are using it.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.