承接 saverty/errors_handling 相关项目开发

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

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

saverty/errors_handling

Composer 安装命令:

composer require saverty/errors_handling

包简介

Laravel Errors Handling allow you to manage errors codes. Sometimes HTTP status aren't enought. With this package you can create your own status with a short description to share it with your team.

README 文档

README

Laravel Errors Handling allow you to manage errors codes. Sometimes HTTP status aren't enought. With this package you can create your own status with a short description to share it with your team.

Installation

Install the package using composer

composer require saverty/errors_handling

Publish the configuration

php artisan vendor:publish --provider="Saverty\ErrorsHandling\ErrorsHandlingServiceProvider" --tag="config"

Go to your app.php and add the provider

"providers"[
	...
    Saverty\ErrorsHandling\ErrorsHandlingServiceProvider::class,
]

Add your codes

Go to errors_handling.php config file and follow the example. Your codes can be grouped by category. Each code needs a code, a name and a description

return [
    //Group your codes 
    "Authentifcation" => [
    
        //Detail your code
        "AUTH001" => [
            "name" => "Login Fail",
            "description" => "Email or password is wrong"
        ]
     ]
]

Use the package

use Saverty\ErrorsHandling\ErrorsHandling;

Add a code error

$errors = new ErrorsHandling();

$errors->add("AUTH001");

Add multiple errors

$errors = new ErrorsHandling();
$errors->add('AUTH001')->add('AUTH002');

Group your errors

$errors = new ErrorsHandling();

$errors->add('AUTH001', 'email')->add('AUTH002','email');
$errors->add('AUTH003', 'name')->add('AUTH004','name');

Check if errors are presents

if($errors->hasErrors()){
    //Errors 
}else{
    // No errors
}

Return errors as an array

$errors->toArray();

Return errors as a Json

$errors->toJson();

Use the laravel validator

 $validator = Validator::make($request->all(),
        [
            "email" => ['required', 'integer'],
            "password" => ['required', 'email']
        ],
        [
            "email.integer" => "AUTH001"
        ]
 );

 $errors->injectValidator($validator);

Your documentation

You can see the all your codes at this url : {your_domain}/errorshandling

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固