Download the PHP package belca/support-constants without Composer

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

Helpers for constants and enumerations

The documentation is actual for version 1.0.

Supporting classes for constants of PHP.

Named constants and enumerations are used for immutable values. The package classes contain functions for getting a list of constants and their values without thrown exceptions of PHP.

Introduction

Install the package using Composer or manually.

Use one of the classes.

Use their features!

AbstractEnum

AbstractConstants

AbstractConstants is the abstract class for implementing a list of named constants and getting their values.

Function Description
Returns all constants of the class.
The alias of the function.
Returns an array of constants defined in the called class without constants of parrent classes.
Returns all constants of parent classes.
$name - a name of constant.

Returns a value of a given constant if it exists, else returns null.
This is a safe method for calling constants, in otherwise when you calls undefined constants you will catch an error.
$name - a name of constant.

Checks whether a given constant exists and is defined in the class.

See the example below. Down there is implementing of the base (first) class of constants.

Example #1 Implementing the first (parent) class with constants

After implementing the class you can get a list of constants from this class. Use or to do this.

Example #2 Getting all constants from the parent class

If you want to get one value then use the function. The function gets a case-sensitive name of constant. By convention, constant identifiers are always uppercase.

Example #3 Getting values of constants of the class

The Roles class contains the constants for us. You will probably want some other constants. Extend the class to solve the problem. This need exists when you uses third-party classes.

Example #4 Extending the parent class

See the examples of the new child class.

Example #5 Checking of existing constants

Example #6 Getting new constants

Example #6 Getting a value of the replaced constant

You can get some constant using the standard PHP syntax. If you try to take a undefined constant then you will catch an error. If you are not sure about an existing constant then use the function and you will not catch an error.

Example 7 Getting values using the standard PHP function

AbstractEnum

AbstractEnum is the abstract class for implementing a list of named constants and getting their values. It was extended from AbstractConstants.

In contract to the Belca\Support\AbstractConstants class, the Belca\Support\AbstractEnum uses a constant with default value.

Function Description
Returns all constants of the class.
The alias of the function.
Returns an array of constants defined in the called class without constants of parrent classes.
Returns all constants of parent classes.
$name - a name of constant.

Returns a value of a given constant if it exists, else returns null.
This is a safe method for calling constants, in otherwise when you calls undefined constants you will catch an error.
$name - a name of constant.

Checks whether a given constant exists and is defined in the class.
Returns the last defined default constant.

The function that return a list of contains do not return the DEFAULT constant.

This class have a new function: the function. The other functions are the same.

Example #8 Implementing the first (parent) class with a default value

Get the default value using the function.

Example #9 Getting the default value

Also you can get the default value using the PHP syntax.

Example #10 Getting the default value using the PHP syntax

You can redefine the default constant by means of extending class.

Example #11 Redefining the default constant

License

The package and other Belca components are open-sourced software licensed under the MIT license.


All versions of support-constants with dependencies

PHP Build Version
Package Version
No informations.
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 belca/support-constants contains the following files

Loading the files please wait ....