Download the PHP package yethee/enum-bundle without Composer

On this page you can find all versions of the php package yethee/enum-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package enum-bundle

BiplaneEnumBundle

Build Status

This bundle provides a typed enumeration for your Symfony2 project.

Note: For Symfony 2.0.x, you need to use the 1.0.0 release of the bundle.

Note: For Symfony less than 2.7, you need to use the 1.2.0 release of the bundle.

Features

Installation

Add this bundle to your project

Install the bundle by running in a shell:

Add the bundle to your application kernel

Usage

In order to create a typed enumeration, it's enough to extend the base class Biplane\EnumBundle\Enumeration\Enum

Below you can see a simple implementation of enumeration for user roles:

You can create a new instance of the enumeration via the create() factory method, which provides the base class:

$role = UserRoles::create(UserRoles::ADMIN);

If the argument contains an invalid value, an exception of Biplane\EnumBundle\Exception\InvalidEnumArgumentException type will be thrown.

The following code example shows how to get the raw value or the human representation of the enumeration value from the object:

$role->getValue(); // returns string 'ROLE_ADMIN'
$role->getReadable(); // returns string 'Admin'

You can also convert the object to a string to obtain the human representation of the enumeration value:

(string)$role;

Bit flags support

You can extend Biplane\EnumBundle\Enumeration\FlaggedEnum for an enumeration, if a bitwise operation is to be performed on a numeric value.

In this case define enumeration constants in powers of two, that is, 1, 2, 4, 8, and so on. This means the individual flags in combined enumeration constants do not overlap. Also you can create an enumerated constant for commonly used flag combinations, but the values of these constants must not be returned by getPossibleValues() method.

Below you can see the implementation of flags enumeration for permissions list:

You can use a bitwise operation on constants for creating a new instance of the enumeration:

$permissions = Permissions::create(Permissions::READ | Permissions::WRITE);

This type of enumeration provides some additional methods:

Using with Doctrine ORM

You can store a raw value of the enum in the entity, and use casting type in getter and setter:

Or you can create a custom type of DBAL for move the logic of casting type from the entity:

NOTE: You should manually convert the raw value to the valid type for your enumeration, before creating a new instance of the enumeration in convertToPHPValue method. Because into this method always passed the value as string (or null).

After that you should register your type, this can be done through config:

Set your type in the mapping of the entity:

JMSSerializerBundle support

This bundle provides a custom handler for the serializer to allow serialize the Enum object as scalar value to json or xml format. The custom handler uses only for those typed enumerations that are specified in the configuration.

You can to register your typed enumerations through config:


All versions of enum-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6
symfony/framework-bundle Version ^3.4|^4.0
symfony/form Version ^3.4|^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package yethee/enum-bundle contains the following files

Loading the files please wait ....