khody2012/laravel-ami-toolkit

A powerful and developer-friendly Laravel package that provides seamless integration with Asterisk AMI (Asterisk Manager Interface).

Maintainers

Package info

github.com/khody2012/LaravelAmiToolkit

pkg:composer/khody2012/laravel-ami-toolkit

Statistics

Installs: 17

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.6.0.35 2026-02-15 08:32 UTC

This package is auto-updated.

Last update: 2026-03-15 08:41:23 UTC


README

πŸš€ Laravel AMI Toolkit is a powerful, developer-friendly Laravel package for seamless integration with the Asterisk Manager Interface (AMI).

It provides clean abstractions and expressive APIs to connect to Asterisk, listen to AMI events, and send manager commands β€” all while staying idiomatic to Laravel’s ecosystem.

This package is designed for real-time, event-driven telephony applications such as CRMs, call centers, monitoring dashboards, and VoIP-based services.

✨ Features

  • πŸ”Œ Persistent and configurable connection to Asterisk AMI
  • πŸ“‘ Listen to real-time AMI events (Dial, Hangup, Queue, etc.)
  • ⚑ Send AMI actions (Originate, Hangup, Ping, Command, …)
  • 🧩 Laravel Event & Listener integration
  • πŸ§ͺ Testable architecture with mockable components
  • πŸ› οΈ Clean, extensible, and well-structured codebase
  • πŸ”’ Secure authentication handling
  • πŸ“¦ Laravel auto-discovery support

πŸ“¦ Installation

Install the package via Composer:

composer require khody2012/laravel-ami-toolkit

⚑ Requirements

  • PHP 8.1+
  • Laravel 9.x, 10.x, 11.x, 12.x

βš™οΈ Configuration

Publish the configuration file:

php artisan vendor:publish --tag=ami-config

This will create config/ami.php.

Example configuration

return [
    'host' => env('AMI_HOST', '127.0.0.1'),
    'port' => env('AMI_PORT', 5038),
    'username' => env('AMI_USERNAME'),
    'password' => env('AMI_PASSWORD'),
    'timeout' => 5,
    'auto_reconnect' => true,
];

Add the following variables to your .env file:

AMI_HOST=127.0.0.1
AMI_PORT=5038
AMI_USERNAME=admin
AMI_PASSWORD=secret

πŸš€ Basic Usage

Connecting to Asterisk AMI

use Khody2012\LaravelAmiToolkit\Facades\Ami;

Ami::connect();
$response = Ami::ping();

if ($response->isSuccess()) {
    // Connection alive
}

πŸ“ž AMI Actions

Originate a Call

Ami::originate([
    'Channel'  => 'SIP/1000',
    'Context'  => 'default',
    'Exten'    => '1001',
    'Priority' => 1,
    'Timeout'  => 30000,
]);

Execute a raw AMI command

Ami::command('sip show peers');

Available Events (examples)

  • AmiDialEvent
  • AmiHangupEvent
  • AmiNewChannelEvent
  • AmiQueueMemberEvent
  • AmiBridgeEvent

You can easily extend or map new AMI events.

🧩 Architecture Overview

  • Connection Layer – Handles socket communication and authentication
  • Action Layer – Encapsulates AMI actions
  • Event Layer – Maps AMI events to Laravel events
  • Facade API – Clean developer-facing interface

This layered design keeps the package maintainable, testable, and extensible.

πŸ” Security Notes

  • Credentials are never logged
  • Supports environment-based configuration
  • Connection timeouts and reconnection strategies included

πŸ›£οΈ Roadmap

  • Async / non-blocking event loop
  • Queue-based event handling
  • Horizon & WebSocket integration
  • Dashboard helpers
  • Full API documentation website

🀝 Contributing

Contributions are welcome ❀️

  1. Fork the repository
  2. Create a feature branch
  3. Write tests
  4. Submit a pull request

πŸ“„ License

This package is open-sourced software licensed under the MIT license.

🏷️ Keywords

laravel, asterisk, ami, voip, pbx, telephony, event-driven, call-center, realtime