ryzhov / asterisk-bundle
AsteriskBundle for symfony framework
Installs: 158
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 4
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- ryzhov/pami: ~1.0
This package is not auto-updated.
Last update: 2025-02-02 03:57:17 UTC
README
The AsteriskBundle
provides integration of the Asterisk PAMI
library into the Symfony2 framework.
License
This bundle is released under the MIT license
Installation
Require the bundle and its dependencies with composer:
$ composer require ryzhov/asterisk-bundle
Register the bundle:
// app/AppKernel.php public function registerBundles() { $bundles = array( new Ryzhov\Bundle\AsteriskBundle(), ); }
Usage
Add the asterisk
section in your configuration file:
asterisk: connections: default: host: "%asterisk_host%" port: "%asterisk_ami_port%" username: "%asterisk_ami_username%" secret: "%asterisk_ami_secret%" connect_timeout: 5 read_timeout: 5 clients: main: connection: default logger_channel: ami
Here we configure the connection parameter and the AMI client that our application will have.
In this example your service container will contain the service asterisk.main_client
and
asterisk.ami_connection.default
connection parameters.
AMI client service interface reference here Asterisk PAMI.
Register async event handler with tag asterisk.ami_event_handler
will handle only specified events.
parameters: events: - "PAMI\\Message\\Event\\DeviceStateChangeEvent" - "PAMI\\Message\\Event\\PeerStatusEvent" services: service.event_handler: class: AppBundle\Service\EventHandler calls: - [setLogger, ["@logger"]] tags: - { name: monolog.logger, channel: event } - { name: asterisk.ami_event_handler, client: asterisk.main_client, events: "%events%" }
Event handler example:
namespace AppBundle\Service; use PAMI\Listener\IEventListener; use PAMI\Message\Event\EventMessage; class EventHandler implements IEventListener { . . . public function handle(EventMessage $event) { $this->logger->debug(sprintf('class: "%s" handle', get_class($event))); } }
This is example of code ryzhov/example-asterisk-ami
$ composer create-project ryzhov/example-asterisk-ami
-- configure ami socket parameters here --
asterisk_host (localhost): 127.0.0.1
asterisk_ami_port (5038):
asterisk_ami_username (ami):
asterisk_ami_secret (pass4ami):
--
$ cd example-asterisk-ami
$ php bin/console event-handler