Download the PHP package dreamscapes/enumeration without Composer

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

Enumerations for PHP

Build Status Coverage Status Dependency Status

Every php programmer at some point wants to put some structure to all those constants defined in their code. Usually one would put those constants under a dedicated class, but that's it; no additional features, no real benefit, no nothing.

What if you could get more?

This small library aims at providing additional features to your "Enumerations" - a set of static values that represent something meaningful to your code.

The problem with constants

Let's say our program will work with animals - various different animals, and we would like each type of animal to have a distinct value ( which I completely made up in this example ). Here's what many programmers currently do:

While this certaily works, there is a better way of defining those.

Defining the constants as a class has several benefits:

  1. You can use real namespacing, which can save you a few typing when using the class
  2. It feels more natural to use Animal::Horse than MYAPP_ANIMAL_HORSE
  3. Since it's a class it opens up new possibilities and ideas -> that's where this library comes to use :)

How this library helps

The above example with a class introduces some issues but also opens up new possibilities.

  1. There's nothing preventing the programmer from instantiating the class
  2. What if you wanted to do it the opposite way? -> you have a value and you want to know the constant's name that holds such value in the enumeration?
  3. What if you wanted to check if a constant is defined in the Enumeration?
  4. What if you wanted to type-hint an enumerated value in a function/method's parameter list?

Let's take a look at another example that demonstrates the use of Enumerations provided by this library.

As you can see, suddenly there's much more you can possibly do with a class as simple as enumeration can be. Learn more in the API Docs which also include code examples and full method descriptions.

Semantic methods

Enumeration contains several semantically named methods you can use to write code that can be understood simply by looking at the code.

Consider following example:

More methods are available - be sure to check out API Docs!

Installation

Via Composer:

composer require dreamscapes\enumeration:dev-master

Composer's autoloading is supported so as long as you require "vendor/autoload.php"; somewhere in your code you can simply start using it.

Documentation

API documentation is available online - it includes all public methods you can use and also several code samples and use cases.

Offline documentation

Sure! Just install the development dependencies and generate the docs.

Documentation is now available at ./docs/index.html.

License

This software is licensed under the BSD (3-Clause) License. See the LICENSE file for more information.


All versions of enumeration with dependencies

PHP Build Version
Package Version
Requires php Version >=5.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 dreamscapes/enumeration contains the following files

Loading the files please wait ....