Download the PHP package eloquent/constance without Composer

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

Constance

PHP constants as enumerations.

The most recent stable version is 0.1.1 Current build status image Current coverage status image

Installation and documentation

What is Constance?

Constance is a library for representing PHP constants as an enumerated type. Constance supports both class-level and global constants, and is built upon a powerful enumeration library to provide a rich feature set.

Amongst other uses, Constance allows a developer to:

Constance is most useful for dealing with pre-defined constants that the developer has no control over. If it is within the developer's control to implement a first-class enumeration, then the recommended approach is to use an enumeration library directly.

Implementing an enumeration of constants

Constance does not provide any concrete classes, but instead provides abstract base classes to make implementation of constant enumerations extremely simple. There are two abstract base classes - AbstractClassConstant for class-level constants, and AbstractGlobalConstant for global constants.

Class-level constants

This example demonstrates how to define an enumeration of PDO attributes:

As the example demonstrates, Constance enumerations are extremely simple to implement. The constant CONSTANCE_CLASS tells Constance which class to inspect for constants, and the optional constant CONSTANCE_PATTERN is a regular expression used to limit which of the constants defined in CONSTANCE_CLASS are defined as members of this enumeration. In this particular case, the expression limits the members to constants starting with ATTR_.

This enumeration can now be used to retrieve information about a PDO attribute constant when only its value is known at run-time:

PdoAttribute can also be used as a type hint that will only accept valid PDO attributes. Note the special static call syntax for accessing members of an enumeration:

Global constants

This example demonstrates how to define an enumeration of PHP error levels:

Global constants are even simpler to implement than class-level constants. The optional constant CONSTANCE_PATTERN is a regular expression used to limit which globally defined constants are defined as members of this enumeration. In this particular case, the expression limits the members to constants starting with E_.

The above enumeration will contain members for all the defined PHP error level constants, such as E_NOTICE, E_WARNING, E_ERROR, E_ALL, and E_STRICT. Note that Constance provides some limited bitwise helper methods for dealing with such sets of constants with bitwise values, which will be discussed in a separate section.

Bitwise logic

Constance provides some methods for dealing with sets of constants that have bitwise values. The PHP error levels enumeration above serves as a good example of such a set.

Assuming the ErrorLevel enumeration described above, the set of members included in E_ALL can be determined like so:

$members now contains an array of enumeration members representing all the error levels included in E_ALL for the current run-time environment. Conversely, the members that are not included can be determined just as easily:

A bit-mask can also be generated for an arbitrary set of enumeration members, like so:

$bitmask now contains a bit-mask that matches only E_NOTICE or E_DEPRECATED.

Lastly, checking whether a given enumeration member matches a bit-mask is also extremely simple:

$isStrictByDefault will now contain a boolean value indicating whether E_ALL includes strict standards warnings for the current run-time environment.


All versions of constance with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
eloquent/enumeration Version ~5
icecave/isolator Version ~2
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 eloquent/constance contains the following files

Loading the files please wait ....