承接 danielescherzer/define-deprecated 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

danielescherzer/define-deprecated

最新稳定版本:v1.0.0

Composer 安装命令:

composer require danielescherzer/define-deprecated

包简介

Allow defining deprecated global constants at runtime without dropping PHP <8.5 support

README 文档

README

About

This composer library implements a way to define constants at runtime that should be marked as deprecated. On PHP 8.4 and below, the constant is defined using define(), while on PHP 8.5 and above, the constant is defined using eval() with the #[\Deprecated] attribute applied.

For background, see this blog post - other than eval() there is no easy way to make use of the ability to deprecate constants on PHP 8.5 without also requiring PHP 8.5 as the minimum supported version of the code.

Installation

The library is meant to be installed via composer, e.g. using composer require danielescherzer/define-deprecated.

It supports (and is tested against) PHP 8.1 and later.

Usage

The primary entrypoint of this library is the function \DanielEScherzer\DefineDeprecated\define_deprecated() which accepts a name, value, deprecation message, and deprecation version. It wraps around the \DanielEScherzer\DefineDeprecated\ConstantDefiner class which holds the actual logic; since PHP does not yet support function autoloading, the define_deprecated() function is always loaded.

To use it:

<?php

use function DanielEScherzer\DefineDeprecated\define_deprecated;

define_deprecated( 'MY_CONSTANT', true, 'Do not use this', '1.0' );

// This will output "bool(true)", and on PHP 8.5+ also emit deprecation warnings
var_dump( MY_CONSTANT );

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固