1. Go to this page and download the library: Download lishun/enums library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
lishun / enums example snippets
use Lishun\Enums\Annotations\EnumCase;
use Lishun\Enums\Interfaces\EnumCaseInterface;
use Lishun\Enums\Traits\EnumCaseGet;
/**
* @method getTest()
*/
enum DemoEnum implements EnumCaseInterface
{
use EnumCaseGet;
#[EnumCase(msg: '系统错误', data: 1, group: 'sys', ext: ['test'=>1,'type'=>2])]
case SYSTEM_ERROR;
#[EnumCase(msg: '系统错误2', data: 2, group: ['sys', 'sys2'])]
case SYSTEM_ERROR2;
#[EnumCase('系统错误3', 2)]
case SYSTEM_ERROR3;
}
use Lishun\Enums\Annotations\EnumCode;
use Lishun\Enums\Annotations\EnumCodePrefix;
use Lishun\Enums\Interfaces\EnumCodeInterface;
use Lishun\Enums\Traits\EnumCodeGet;
#[EnumCodePrefix(10, '系统错误码')]
enum DemoCode: int implements EnumCodeInterface
{
use EnumCodeGet;
// 错误码: 10500, 错误信息: 系统错误
#[EnumCode('系统错误')]
case SYSTEM_ERROR = 500;
#[EnumCode(msg:'系统错误1')]
case SYSTEM_ERROR1 = 501;
#[EnumCode(msg:'系统错误2',ext:['test'=1])]
case SYSTEM_ERROR2 = 502;
}