PHPackages                             famelo/features - 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. famelo/features

ActiveTypo3-flow-package

famelo/features
===============

3812[2 issues](https://github.com/mneuhaus/Famelo.Features/issues)PHP

Since May 1Pushed 11y ago2 watchersCompare

[ Source](https://github.com/mneuhaus/Famelo.Features)[ Packagist](https://packagist.org/packages/famelo/features)[ RSS](/packages/famelo-features/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Famelo.Features
---------------

[](#famelofeatures)

This Package provides a Service and a ViewHelper to help you roll out new features easily.

Creating a new Feature
----------------------

[](#creating-a-new-feature)

Features are specified in a separate Configuration file called "Features.yaml"

Here's an example:

```
-
  name: OnyForAdminstators
  condition: hasRole('My.Package:Administrator')

-
  name: OnlyForMneuhaus
  condition: isUser('mneuhaus')

-
  name: OnlyAfterThisDate
  condition: afterDate('22.11.2013')

-
  name: onlyGuests
  condition: isGuest()

-
  name: onlyLoggedIn
  condition: isNotGuest()

-
  name: only25PercentOfTheUsers
  condition: userPercentage(25)

-
  name: onlyWithMatchingClientIp
  condition: clientIp('127.0.0.1')

-
  name: combination
  condition: hasRole('My.Package:Administrator') && userPercentage(25)

-
  name: combination2
  condition: hasRole('My.Package:Administrator') || afterDate('22.11.2013')
```

Using the FeatureService
------------------------

[](#using-the-featureservice)

you can easily inject the featureService like this:

```
	/**
	 * The featureService
	 *
	 * @var \Famelo\Features\FeatureService
	 * @Flow\Inject
	 */
	protected $featureService;
```

Then you can ask it if the feature you want to act upon is activated for the current user:

```
if ($this->featureService->isFeatureActive("myFeature")) {
	do some cool stuff
}
```

Using the ActiveViewHelper
--------------------------

[](#using-the-activeviewhelper)

For convenience there is a wrapper for the featureService for fluid:

```
{namespace feature=Famelo\Features\ViewHelpers}

	show my cool feature

```

alternatively you can use it like the ifViewHelper with then/else

```

		show my cool feature

		show some other stuff

```

Settings
--------

[](#settings)

```
Famelo:
  Features:
    # You can change this setting to use your own ConditionMatcher with more specific functions
    # you might need
    conditionMatcher: \Famelo\Features\Core\ConditionMatcher

    # What should happen if the service is asked about a feature it doesn't now?
    # can be: active, inactive, exception
    # exception is the default and will throw an exception because you probably
    # mistyped some feature name
    noMatchBehavior: exception
```

Additional ConditionMatchers
----------------------------

[](#additional-conditionmatchers)

You can add as many custom conditionMatches as you like. All you have to do is implement a ConditionMatcher based on the "\\Famelo\\Features\\Core\\ConditionMatcherInterface". You can add as many methods and injected properties as you like. Any method of that class will be available as an eel method under a variable called as the NAME constant you specified. You can add any number of parameters for the methods as well.

**Example:**

```
