You should check out the Ethereum-php Listener and Indexer
As opposed to above it will also work with clients who don't support EthFilter like Infura.
1) Extend a Ethereum\SmartContract and add event handlers with "onEventName"
class CallableEvents extends SmartContract { public function onCalledTrigger1 (EthEvent $event) { echo '### ' . substr(__FUNCTION__, 2) . "(\Ethereum\EmittedEvent)\n"; var_dump($event); } public function onCalledTrigger2 (EthEvent $event) { echo '### ' . substr(__FUNCTION__, 2) . "(\Ethereum\EmittedEvent)\n"; var_dump($event); } }
2) Initialize your Contracts (in this Example from Truffle builds)
$web3 = new Ethereum('http://192.168.99.100:8545'); $networkId = '5777'; // Contract Classes must have same name as the solidity classes for this to work. $contracts = SmartContract::createFromTruffleBuildDirectory( 'YOUR/truffle/build/contracts', $web3, $networkId );
3) Create a Event processor
// process any Transaction from current Block to the future. new ContractEventProcessor( $web3, $contracts, 'latest', 'latest' );
Code is based on reactPHP.
You'll find more examples for Block or Event processing here.