PHP SDK
innovafour/iforevents for Laravel, Symfony, plain PHP and CLIs
composer require innovafour/iforevents
composer require innovafour/iforevents-mixpanel innovafour/iforevents-segment # optional adaptersuse IForevents\Iforevents;
$analytics = Iforevents::create(getenv('IFOREVENTS_PROJECT_KEY'));
$analytics->identify('user_123', ['email' => '[email protected]', 'plan' => 'pro']);
$analytics->track('invoice_paid', ['amount' => 120, 'currency' => 'USD']);
$analytics->page('/pricing');
$analytics->reset(); // logout
$analytics->shutdown(); // also runs at script endPHP 8.1+, ext-json and ext-curl only. PHP has no background timers: a batch is sent when it reaches batchSize, when a partial batch is older than flushInterval and another event arrives, on flush()/shutdown(), and at script end. SessionStorage keeps the anonymous id in the visitor's PHP session; FileStorage serves CLIs.
use IForevents\{APIConfig, APIIntegration, Iforevents, SessionStorage};
use IForevents\Integrations\MixpanelIntegration;
$config = new APIConfig('pk_...');
$config->storage = new SessionStorage();
$analytics = new Iforevents([new APIIntegration($config), new MixpanelIntegration('MIXPANEL_TOKEN')]);
$analytics->init();Exceptions: IForevents\APIException, AuthException, QuotaExceededException, RateLimitedException.
Source: iforevents-sdks/php.