The Laravel A/B Test package helps you quickly set up A/B tests and feature flags in a Laravel app. The package uses the self-hosted ABRouter service (which also has paid hosted options) to power the A/B and feature flag settings.
Here’s an example controller using this package to A/B test UI features, in this case, a button color:
5 public function __invoke(Client $client)
7 $userId = auth()->user()->id;
8 $buttonColor = $client->experiments()->run($userId, 'button_color');
9 return view('button', [
10 'color' => $buttonColor->getBranchId(),
Another useful feature is feature flags, which help you roll experimental/new features out to customers incrementally, toggling on/off without a code redeploy:
1$isEnabledButton = $client->featureFlags()
5 'enabledButtonFeatureFlag' => $isEnabledButton,
You’ll need to set up the ABRouter service to use this package. You can learn more about this service from the ABRouter Docs. You can learn about this package, get full installation instructions, and view the source code on GitHub.
Credit: Source link