Download the PHP package jimchen/laravel-trigger without Composer
On this page you can find all versions of the php package jimchen/laravel-trigger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download jimchen/laravel-trigger
More information about jimchen/laravel-trigger
Files in jimchen/laravel-trigger
Download jimchen/laravel-trigger
More information about jimchen/laravel-trigger
Files in jimchen/laravel-trigger
Vendor jimchen
Package laravel-trigger
Short Description MySQL trigger base on MySQLReplication
License MIT
Homepage https://github.com/jimchen/laravel-trigger
Package laravel-trigger
Short Description MySQL trigger base on MySQLReplication
License MIT
Homepage https://github.com/jimchen/laravel-trigger
Please rate this library. Is it a good library?
Informations about the package laravel-trigger
laravel-trigger
Subscribe MySQL events like jQuery, base on php-mysql-replication
中文说明
MySQL server settings
In your MySQL server configuration file you need to enable replication:
[mysqld]
server-id = 1
log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days = 10
max_binlog_size = 100M
binlog_row_image = full
binlog-format = row #Very important if you want to receive write, update and delete row events
Mysql replication events explained https://dev.mysql.com/doc/internals/en/event-meanings.html
Mysql user privileges:
GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'user'@'host';
GRANT SELECT ON `dbName`.* TO 'user'@'host';
Installation
Laravel
install
composer require jimchen/laravel-trigger
publish config
php artisan vendor:publish --provider="JimChen\Trigger\TriggerServiceProvider"
Lumen
install
composer require jimchen/laravel-trigger
edit bootstrap/app.php
add:
$app->register(JimChen\Trigger\TriggerServiceProvider::class);
...
$app->configure('trigger');
publish config and route
php artisan trigger:install [--force]
Configure
edit .env
, add:
TRIGGER_HOST=192.168.xxx.xxx
TRIGGER_PORT=3306
TRIGGER_USER=username
TRIGGER_PASSWORD=password
...
Usage
php artisan trigger:start [-R=xxx]
Subscriber
more subscriber usage
Event Route
common
$trigger->on('database.table', 'write', function($event) { /* do something */ });
multi-tables and multi-evnets
$trigger->on('database.table1,database.table2', 'write,update', function($event) { /* do something */ });
multi-events
$trigger->on('database.table1,database.table2', [
'write' => function($event) { /* do something */ },
'update' => function($event) { /* do something */ },
]);
action as controller
$trigger->on('database.table', 'write', 'App\\Http\\Controllers\\ExampleController'); // call default method 'handle'
$trigger->on('database.table', 'write', 'App\\Http\\Controllers\\ExampleController@write');
action as callable
class Foo
{
public static function bar($event)
{
dump($event);
}
}
$trigger->on('database.table', 'write', 'Foo@bar'); // call default method 'handle'
$trigger->on('database.table', 'write', ['Foo', 'bar']);
action as job
Job
namespace App\Jobs;
class ExampleJob extends Job
{
private $event;
public function __construct($event)
{
$this->event = $event;
}
public function handle()
{
dump($this->event);
}
}
Route
$trigger->on('database.table', 'write', 'App\Jobs\ExampleJob'); // call default method 'dispatch'
$trigger->on('database.table', 'write', 'App\Jobs\ExampleJob@dispatch_now');
Event List
php artisan trigger:list [-R=xxx]
Terminate
php artisan trigger:terminate [-R=xxx]
Thanks to
All versions of laravel-trigger with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.1.0
laravel/framework Version ^5.5|^5.6|^5.7|^5.8|^6.0|^7.0
krowinski/php-mysql-replication Version ^6.0
laravel/framework Version ^5.5|^5.6|^5.7|^5.8|^6.0|^7.0
krowinski/php-mysql-replication Version ^6.0
The package jimchen/laravel-trigger contains the following files
Loading the files please wait ....