Download the PHP package mindtwo/native-enum without Composer

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

Laravel Native PHP 8.1 Enums

Latest Version on Packagist Build Status Total Downloads

mindtwo GmbH

Enums are an invaluable tool for any developer working with PHP. They provide a way to easily and efficiently define a set of constants that can be used throughout a project. Enums also help to make code more maintainable and scalable. For example, they can help to define a set of values that must stay consistent throughout the project, like a list of permissions or statuses. This helps ensure that the same values are used in all the relevant parts of the code and that any changes are made in one place. Additionally, enums help to reduce the amount of manual testing needed since the values are already defined. Furthermore, enums provide a way for developers to quickly check for valid values, making it easier to spot errors in code and ensure that the application behaves as expected. Finally, enums are strongly typed, meaning that they can help to ensure that the correct type of data is used in each part of the application, which can help to improve overall code quality.

Inspired by the package BenSampo/laravel-enum this one uses the new native enums classes in PHP. The native functions are extended to work easily ams seamlessly with them in Laravel-based systems.

Everyone is welcome to contribute.

Enojy the Package!

Overview

Install

Installing the PHP Composer Package

Laravel Native PHP 8.1 Enums is a powerful package that can help you construct and maintain robust and scalable Laravel-based systems.

Requirements

Composer install

Before you begin, you'll need to make sure you have the listed requirements and Composer installed on your system. You can find instructions for doing so here.

Once you have Composer installed, you can install "Laravel Native PHP 8.1 Enums" by running the following command from your project directory:

After the installation is complete, you'll now be ready to start using native enums in your project. Have fun!

Create enum

Artisan command

You can use the following Artisan command to generate a new native enum class in your project:

Manual enum creation

You can also create a new native enum manually. The structure should look like this:

Usage

Base usage

Get specific enum values

Get specific enum names

Use static calls to get the primitive value

Validation

Enum value

You may validate that an enum value passed to a controller is a valid value for a given enum by using the EnumValue rule.

By default, type checking is set to strict, but you can bypass this by passing false to the optional second parameter of the EnumValue class.

Enum name

You can also validate on names using the EnumName rule. This is useful if you're taking the enum name as a URL parameter for sorting or filtering for example.

Enum instance

Additionally you can validate that a parameter is an instance of a given enum.

Localized enum

The Enum has to implement the LocalizedEnum interface:

Translation files can be placed here lang/en/enums.php like:

To get a translated name of a selected enum value:

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

Contributing

Please see CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of native-enum with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/collections Version ^8.0|^9.0|^10.0|^11.0
illuminate/contracts Version ^8.0|^9.0|^10.0|^11.0
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
illuminate/translation Version ^8.0|^9.0|^10.0|^11.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 mindtwo/native-enum contains the following files

Loading the files please wait ....