百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

php-binlog

> 数据库
开源

用于 MySQL Binlog 的 PHP 客户端

188 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于 MySQL Binlog 的 PHP 客户端

PHP Binlog

We have deployed it in produtive enviroment, and I posted an article for it (but in Chinese), http://guweigang.com/blog/2013/11/18/mysql-binlog-in-realtime/. Hope it will help you.


A PHP-Client for mysql replication listener API.

You can use it to connect to a MYSQL server which produces BINLOG, and get BINLOG events in real-time, just like a Async-Trigger.

You know, we always need to use different components to do a good job, serve a good service. Just like we use MYSQL to storage all our data, use REDIS as a cache server, and use LUCENE as a search engine. The differences between MYSQL and other components will affect the sorting result, and therefore affect user experience, especially for time-sensitive service.

Our group use PHP to develop web projects. So if we have a PHP extension to do the data trigger job between different components, everything will be easy. This is what we do and why we do.

Dependence

  • MySQL Replication Listener Library (https://github.com/BullSoft/mysql-replication-listener)
  • PHP 5.3.X
  • MySQL 5.4 and lower,,, for MySql 5.7, you can checkout the branch bundle-new-binlog and install the extension in cpp_ext.

Install

First, install mysql-replication-listener.

$ cmake . -DCMAKE_INSTALL_PREFIX=/home/work/mysql-replication

$ make && make install

Then change to php-binlog ext directory,

$ /home/work/local/php/bin/phpize

$ ./confingure --with-php-config=/home/work/local/php/bin/php-config --with-mysql-binlog=/home/work/mysql-replication

$ make

$ make install

Example

注:Binlog为行格式

…

Update_rows

sql
update `type` set type_id = 22 WHERE id in (58, 59);
…

Delete_rows

sql
delete from `type` WHERE id in (58, 59);
…

Write_rows

sql
insert into type values (Null, "Hello, World", "Best world", 4, 0), (NULL, "你好,世界", "世界很美好", 3, 5);
…

Reference

MySQL Replication Listener:

http://cdn.oreillystatic.com/en/assets/1/event/61/Binary%20log%20API_%20A%20Library%20for%20Change%20Data%20Capture%20using%20MySQL%20Presentation.pdf

http://dev.mysql.com/doc/internals/en/index.html

http://dev.mysql.com/doc/refman/5.1/en/mysqlbinlog-row-events.html

http://dev.mysql.com/doc/internals/en/replication-protocol.html Feedback

Issues and contributions are welcome.

Thank you!

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C++mysqlmysql-replication-listenerphpphp-binlog

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库