cse/base-exceptions 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

cse/base-exceptions

Composer 安装命令:

composer require cse/base-exceptions

包简介

This library provides a simple work with exceptions for both development and production.

README 文档

README

English | Русский

EXCEPTIONS CSE BASE

Travis (.org) Codecov Scrutinizer code quality

Packagist Minimum PHP Version Packagist GitHub repo size

This library provides a simple work with exceptions for both development and production.

Project repository: https://github.com/cs-eliseev/base-exceptions

DEMO

try {
    ..
    $code = 0;
} catch (CseExceptions $e) {
    ...
} catch (Throwable $e) {
    $code = $e->getCode();
}
CseExceptions::getErrorMsg($code);
// Unknown error

Introduction

CSE BASE is a set of libraries written in PHP specifically to extend your classes.

A set of basic methods for creating your classes is what you need to quickly create web applications. EXCEPTIONS CSE BASE, allows you to extend classes with exceptions.

CSE BASE was created for the rapid development of web applications.

CSE Base project:

Below you will find some information on how to init library and perform common commands.

Install

You can find the most recent version of this project here.

Composer

Execute the following command to get the latest version of the package:

composer require cse/base-exceptions

Or file composer.json should include the following contents:

{
    "require": {
        "cse/base-exceptions": "*"
    }
}

Git

Clone this repository locally:

git clone https://github.com/cs-eliseev/base-exceptions.git

Download

Download the latest release here.

Usage

View test model: ModelExceptions.php

See examples: examples-exceptions.php

Create Model Exception

Examples:

class ModelExceptions extends CseExceptions
{
    const ERROR_EXAMPLE_CODE_1 = 1;
    const ERROR_EXAMPLE_CODE_2 = 2;
    const ERROR_EXAMPLE_CODE_3 = 3;

    /**
     * @var array
     */
    protected static $errorsMsg = [
        self::ERROR_EXAMPLE_CODE_1 => 'Error code 1',
        self::ERROR_EXAMPLE_CODE_2 => 'Error code 2',
        self::ERROR_EXAMPLE_CODE_3 => 'Error code 3',
    ];
}

Use check instance

Examples:

try {
    ...
    throw new ModelExceptions('CseExceptions');
} catch (CseExceptions $e) {
    $e->getMessage();
    // CseExceptions
} catch (Exception $e) {
    // Last Exception
} catch (Throwable $e) {
    // Last Throwable
}

Throw exception by code error

Examples:

ModelExceptions::throwException(ModelExceptions::ERROR_EXAMPLE_CODE_1);
// Error code 1

Add msg to exception:

ModelExceptions::throwException(ModelExceptions::ERROR_EXAMPLE_CODE_2, ' - msg test');
// Error code 2 - msg test

Default error msg:

ModelExceptions::throwException(4);
// Unknown error

Get error msg by code error

Examples:

ModelExceptions::getErrorMsg(ModelExceptions::ERROR_EXAMPLE_CODE_3);
// Error code 3

Default error msg:

ModelExceptions::getErrorMsg(4);
// Unknown error

Testing & Code Coverage

PHPUnit is used for unit testing. Unit tests ensure that class and methods does exactly what it is meant to do.

General PHPUnit documentation can be found at https://phpunit.de/documentation.html.

To run the PHPUnit unit tests, execute:

phpunit PATH/TO/PROJECT/tests/

If you want code coverage reports, use the following:

phpunit --coverage-html ./report PATH/TO/PROJECT/tests/

Used PHPUnit default config:

phpunit --configuration PATH/TO/PROJECT/phpunit.xml

Donating

You can support this project here. You can also help out by contributing to the project, or reporting bugs. Even voicing your suggestions for features is great. Anything to help is much appreciated.

License

The EXCEPTIONS CSE BASE is open-source PHP library licensed under the MIT license. Please see License File for more information.

GitHub @cs-eliseev

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固