承接 irap/http-codes 相关项目开发

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

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

irap/http-codes

最新稳定版本:1.2.0

Composer 安装命令:

composer require irap/http-codes

包简介

A package to make error codes easier.

README 文档

README

To use this package of defines you need to manually include the

Usage

Download this package into your project with the command:

composer require irap/http-codes

Below is an example of using the package to return a 404 JSON response for an API request.

<?php
http_response_code(iRAP/Http/HttpCode::NOT_FOUND);

$body = array(
    "result" => "error",
    "message" => "Resource not found.",
);

header('Content-Type: application/json');
die(json_encode($body));

Alternatively...

<?php
use iRAP\Http\HttpCode;

http_response_code(HttpCode::NOT_FOUND);

$body = array(
    "result" => "error",
    "message" => "Resource not found.",
);

header('Content-Type: application/json');
die(json_encode($body));

There's also a method to check if a passed parameter is a valid http status code based on this.

<?php
use iRAP\Http\HttpCode;

if (HttpCode::isValid(404)) {
    echo "Valid HTTP status code";
} else {
    echo "Invalid HTTP status code";
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-12-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固