Manage Events, Feature Flags, and More with PostHog for Laravel

Laravel PostHog is a package integrating PostHog—a platform to analyze, test, observe, and deploy new features—with Laravel. It builds on top of the posthog-php package, offering a Facade and simplified configuration in your Laravel app:

use QodeNL\LaravelPosthog\Facades\Posthog;

Posthog::capture('event name', ['property' => 'value']);

PostHog has a variety of features that you can use, and the PHP/Laravel package specifically provides the following features that you can integrate:

PostHog doesn't have a Laravel Pennant feature flag driver, but you can use PostHog's feature flags directly via the package:

use QodeNL\LaravelPosthog\Facades\Posthog;

Posthog::getAllFlags();
Posthog::isFeatureEnabled('myFeatureFlagKey');

// Return true/false/payload (if set)
Posthog::getFeatureFlag('myFeatureFlagKey');

You can learn more about this package, get full installation instructions, and view the source code on GitHub. The PostHog documentation has more examples of using this package with Laravel and PHP.


The post Manage Events, Feature Flags, and More with PostHog for Laravel appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.