Download the PHP package vaened/php-enum without Composer

On this page you can find all versions of the php package vaened/php-enum. 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 php-enum

PHP Enum

Build Status Scrutinizer Code Quality

Friendly enumeration implementation.

Installation

PHP Enum requires PHP 8.

To get the latest version, simply require the project using Composer:

Declaration

To create an enumeration it is necessary to extend from Vaened\Enum\Enum, in addition to creating constants for each value of the enumeration. This library has the ability to add attributes for each enumeration, very similar to the enumerations in java.

Usage

Once the enumeration is implemented, you can use its values in the following way. The library uses __callStatic to create instances of a specified enumeration, according to the requested value.

In case you want autocompletion ID, you can define the methods manually.

or if you are using some ID that supports phpdocs, you can do something like this:

Advanced

There may be specific cases where you need to add some additional attribute to the enumeration. To do this, you will need to override the protected static method attributes available in all Enum children, here you must define the attributes you will use for each enumeration.

Must use the Vaened\Enum\Attributor class.

To get any attribute, you can use the protected method attribute which gets the name of the attribute as parameter

API

Method Description Returns
static::create(string $value) Create an instance for the given value. Enum
static::instantiate(string $constant) Instantiate from constant name. Enum
static::isValid(string $value) Check if the given value belongs to the enumaracion. boolean
static::values() Returns an array with all the enumeration values. Enum[]
$instance->value() Returns the value of an enumeration. string
$instance->key() Returns the constant name of an enumeration. string
$instance->equals(string $value) Verify that the value of an enumeration is equal to a given value. boolean
$instance->match(Enum $enum) Verify that the value of an enumeration is equal to a given enum. boolean

More documentation

You can find a lot of comments within the source code as well as the tests located in the tests directory.


All versions of php-enum with dependencies

PHP Build Version
Package Version
Requires php Version ^8.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 vaened/php-enum contains the following files

Loading the files please wait ....