PHP library for handling exceptions and errors.
- Installation
- Requirements
- Quick Start and Examples
- Available Methods
- Usage
- Tests
- Exception Handler
- Images
- Contribute
- Repository
- Licensing
- Copyright
The preferred way to install this extension is through composer.
To install PHP ErrorHandler library, simply:
$ composer require Josantonius/ErrorHandler
The previous command will only install the necessary files, if you prefer to download the entire source code (including tests, vendor folder, exceptions not used, docs...) you can use:
$ composer require Josantonius/ErrorHandler --prefer-source
Or you can also clone the complete repository with Git:
$ git clone https://github.com/Josantonius/PHP-ErrorHandler.git
This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher.
To use this class, simply:
require __DIR__ . '/vendor/autoload.php';
use Josantonius\ErrorHandler\ErrorHandler;
Available methods in this library:
ErrorHandler::setCustomMethod();
Example of use for this library:
<?php
require __DIR__ . '/vendor/autoload.php';
use Josantonius\ErrorHandler\ErrorHandler;
/**
* It is recommended to instantiate the class in a base file as the index.php */
new ErrorHandler;
/**
* Optionally you can enter one or more methods to be executed instead the
* default view. The indicated method will receive an array with the
* following parameters:
*
* [
* 'type' => 'Error|Exception',
* 'message' => 'exception|error message',
* 'file' => 'exception|error file',
* 'line ' => 'exception|error line',
* 'code' => 'exception|error code',
* 'http-code' => 'HTTP response status code',
* 'mode' => 'PHP|HHVM',
* ];
*
*/
$class = $this;
$method = 'customMethodResponse';
$times = 0; // Times number to repeat this method in case of multiple errors
ErrorHandler::SetCustomMethod($class, $method, $times);
To use the test class, simply:
<?php
$loader = require __DIR__ . '/vendor/autoload.php';
$loader->addPsr4('Josantonius\\ErrorHandler\\Tests\\', __DIR__ . '/vendor/josantonius/errorhandler/tests');
use Josantonius\ErrorHandler\Tests\ErrorHandlerTest;
Available test methods in this library:
ErrorHandlerTest->testSetCustomMethod1();
ErrorHandlerTest->testSetCustomMethod2();
ErrorHandlerTest->testSetCustomMethod3();
ErrorHandlerTest->testSProvokeException();
ErrorHandlerTest->testSProvokeWarning();
ErrorHandlerTest->testSProvokeNotice();
ErrorHandlerTest->testSProvokeUserError();
ErrorHandlerTest->testSProvokeUserNotice();
ErrorHandlerTest->testSProvokeUserWarning();
This library uses exception handler that you can customize.
- Check for open issues or open a new issue to start a discussion around a bug or feature.
- Fork the repository on GitHub to start making your changes.
- Write one or more tests for the new feature or that expose the bug.
- Make code changes to implement the feature or fix the bug.
- Send a pull request to get your changes merged and published.
This is intended for large and long-lived objects.
All files in this repository were created and uploaded automatically with Reposgit Creator.
This project is licensed under MIT license. See the LICENSE file for more info.
2017 Josantonius, josantonius.com
If you find it useful, let me know 😉