Download the PHP package dasprid/enum without Composer

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

PHP 7.1 enums

Build Status Coverage Status Latest Stable Version Total Downloads License

It is a well known fact that PHP is missing a basic enum type, ignoring the rather incomplete SplEnum implementation which is only available as a PECL extension. There are also quite a few other userland enum implementations around, but all of them have one or another compromise. This library tries to close that gap as far as PHP allows it to.

Usage

Basics

At its core, there is the DASPRiD\Enum\AbstractEnum class, which by default will work with constants like any other enum implementation you might know. The first clear difference is that you should define all the constants as protected (so nobody outside your class can read them but the AbstractEnum can still do so). The other even mightier difference is that, for simple enums, the value of the constant doesn't matter at all. Let's have a look at a simple example:

If you need to provide constants for either internal use or public use, you can mark them as either private or public, in which case they will be ignored by the enum, which only considers protected constants as valid values. As you can see, we specifically defined the generated magic methods in a class level doc block, so anyone using this class will automatically have proper auto-completion in their IDE. Now since you have defined the enum, you can simply use it like that:

More complex example

Of course, all enums are singletons, which are not cloneable or serializable. Thus you can be sure that there is always just one instance of the same type. Of course, the values of constants are not completely useless, let's have a look at a more complex example:


All versions of enum with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1 <9.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 dasprid/enum contains the following files

Loading the files please wait ....