PHPackages                             toggly/feature-management-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. toggly/feature-management-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

toggly/feature-management-php
=============================

Toggly Feature Management library for PHP with Laravel and WordPress support

00PHPCI passing

Since Mar 4Pushed 2mo agoCompare

[ Source](https://github.com/ops-ai/Toggly.FeatureManagement.PHP)[ Packagist](https://packagist.org/packages/toggly/feature-management-php)[ RSS](/packages/toggly-feature-management-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Toggly Feature Management for PHP
=================================

[](#toggly-feature-management-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/bba96420b3b5a9f6c890054a49e281e99f2dd26016024c7bb93284e777d276c2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f67676c792f666561747572652d6d616e6167656d656e742d7068702e737667)](https://packagist.org/packages/toggly/feature-management-php)[![Total Downloads](https://camo.githubusercontent.com/3630cac8a458df719e57c8435ddf320b2818ee473687a90e1686b2c7d4fe824e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f67676c792f666561747572652d6d616e6167656d656e742d7068702e737667)](https://packagist.org/packages/toggly/feature-management-php)[![License](https://camo.githubusercontent.com/8a7cfec05fa6ee3ca5dbf590f7f39fe653d3e8c5ebcaf40338791f45614ae085/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f67676c792f666561747572652d6d616e6167656d656e742d7068702e737667)](https://packagist.org/packages/toggly/feature-management-php)

A comprehensive PHP library for Toggly feature management with native Laravel and WordPress support.

Features
--------

[](#features)

- **Full Feature Parity**: Matches the functionality of the .NET Toggly.FeatureManagement library
- **Signed Definitions**: ECDSA signature verification for secure feature definitions
- **Real-time Updates**: WebSocket support for instant feature updates (with polling fallback)
- **Usage Statistics**: Automatic tracking of feature usage and user analytics
- **Metrics Collection**: Support for measurements, observations, and counters
- **Snapshot Providers**: Cache, database, and file-based snapshot storage
- **Laravel Integration**: Native Laravel service provider, facade, and middleware
- **WordPress Plugin**: Full WordPress plugin with admin interface and hooks
- **PSR Standards**: Built on PSR-4, PSR-11, PSR-16, PSR-18, and PSR-17

Installation
------------

[](#installation)

### Composer

[](#composer)

```
composer require toggly/feature-management-php
```

Quick Start
-----------

[](#quick-start)

### Laravel

[](#laravel)

1. **Register the service provider** in `config/app.php`:

```
'providers' => [
    // ...
    Toggly\Laravel\ServiceProvider::class,
],
```

2. **Publish the configuration**:

```
php artisan vendor:publish --tag=toggly-config
```

3. **Configure** in `.env`:

```
TOGGLY_APP_KEY=your-app-key
TOGGLY_ENVIRONMENT=Production
TOGGLY_USE_SIGNED_DEFINITIONS=false
```

4. **Use in your code**:

```
use Toggly\Laravel\Facades\Toggly;

// Check if feature is enabled
if (Toggly::isEnabled('new-checkout')) {
    return view('checkout.v2');
}

// With context
$enabled = Toggly::isEnabledFor('premium-feature', [
    'userId' => $user->id,
    'plan' => $user->plan
]);

// State change handler
Toggly::whenFeatureTurnsOn('new-api', function() {
    // Initialize new API
});

// Record usage
Toggly::recordUsage('feature-key');

// Record metrics
Toggly::measure('checkout-completed', 125.50);
Toggly::observe('active-users', 1500);
Toggly::incrementCounter('api-calls', 1);
```

5. **Use middleware** in routes:

```
Route::get('/new-feature', function () {
    return view('new-feature');
})->middleware('feature:new-feature');
```

### WordPress

[](#wordpress)

1. **Install the plugin** by copying to `wp-content/plugins/toggly/`
2. **Activate** the plugin in WordPress admin
3. **Configure** in Settings &gt; Toggly:

    - App Key
    - Environment
    - Base URL (optional)
    - Use Signed Definitions (optional)
4. **Use in templates**:

```
