Skip to content

Commit

Permalink
Merge pull request #33 from Jurj-Bogdan/3.0
Browse files Browse the repository at this point in the history
Added Documentation
  • Loading branch information
alexmerlin authored May 3, 2024
2 parents 364d45a + 02bddae commit 1d1c9ef
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 165 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Continuous Integration"

on:
pull_request:
push:
branches:
tags:

jobs:
ci:
uses: laminas/workflow-continuous-integration/.github/workflows/continuous-integration.yml@1.x
47 changes: 0 additions & 47 deletions .github/workflows/cs-tests.yml

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: docs-build

on:
release:
types: [published]
workflow_dispatch:

jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Build Docs
uses: dotkernel/documentation-theme/github-actions/docs@main
env:
DEPLOY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 0 additions & 47 deletions .github/workflows/static-analysis.yml

This file was deleted.

48 changes: 0 additions & 48 deletions .github/workflows/unit-tests.yml

This file was deleted.

40 changes: 19 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@ Logging Error Handler for DotKernel

[![SymfonyInsight](https://insight.symfony.com/projects/cf1f8d89-f230-4157-bc8b-7cce20c75454/big.svg)](https://insight.symfony.com/projects/cf1f8d89-f230-4157-bc8b-7cce20c75454)


## Adding the error handler

* Add the composer package:
- Add the composer package:

`composer require dotkernel/dot-errorhandler`

`composer require dotkernel/dot-errorhandler:^3.1`
- Add the config provider
- in `config/config.php` add `\Dot\ErrorHandler\ConfigProvider`
- in `config/pipeline.php` add `\Dot\ErrorHandler\ErrorHandlerInterface::class`
- the interface is used as an alias to keep all error handling related configurations in one file
- **IMPORTANT NOTE** there should be no other error handlers after this one (only before) because the other error handler will catch the error causing dot-errorhandler not to catch any error, we recommend using just one error handler unless you have an error-specific handler

- Configure the error handler as shown below

* Add the config provider
- in `config/config.php` add `\Dot\ErrorHandler\ConfigProvider`
- in `config/pipeline.php` add `\Dot\ErrorHandler\ErrorHandlerInterface::class`
+ the interface is used as an alias to keep all error handling related configurations in one file
+ **IMPORTANT NOTE** there should be no other error handlers after this one (only before) because the other error handler will catch the error causing dot-errorhandler not to catch any error, we recommend using just one error handler unless you have an error-specific handler

* Configure the error handler as shown below
config/autoload/error-handling.global.php

configs/autoload/error-handling.global.php
```php
<?php

Expand All @@ -53,20 +52,21 @@ return [
];
```

When declaring the `ErrorHandlerInterface` alias you can choose whether to log or not:
* for logging use `LogErrorHandler`
* for the simple zend expressive handler user `ErrorHandler`
A configuration example for the default logger can be found in `config/log.global.php.dist`.

When declaring the `ErrorHandlerInterface` alias you can choose whether to log or not:

- for logging use `LogErrorHandler`
- for the simple Zend Expressive handler user `ErrorHandler`

The class `Dot\ErrorHandler\ErrorHandler` is the same as the Zend Expressive error handling class
the only difference being the removal of the `final` statement for making extension possible.


The class `Dot\ErrorHandler\LogErrorHandler` is `Dot\ErrorHandler\ErrorHandler` with
The class `Dot\ErrorHandler\LogErrorHandler` is `Dot\ErrorHandler\ErrorHandler` with
added logging support.


As a note: both `LogErrorHandler` and `ErrorHandler` have factories declare in the
package's ConfigProvider. If you need a custom ErrorHandler it must have a factory
As a note: both `LogErrorHandler` and `ErrorHandler` have factories declared in the
package's `ConfigProvider`. If you need a custom ErrorHandler it must have a factory
declared in the config, as in the example.

Example:
Expand Down Expand Up @@ -98,5 +98,3 @@ return [
```

Config examples can be found in this project's `config` directory.


39 changes: 39 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Security Policy

## Supported Versions


| Version | Supported | PHP Version |
|---------|--------------------|-----------------------------------------------------------------------------------------------------------------------|
| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-errorhandler/3.3.2) |
| <= 2.x | :x: | |


## Reporting Potential Security Issues

If you have encountered a potential security vulnerability in this project,
please report it to us at <security@dotkernel.com>. We will work with you to
verify the vulnerability and patch it.

When reporting issues, please provide the following information:

- Component(s) affected
- A description indicating how to reproduce the issue
- A summary of the security vulnerability and impact

We request that you contact us via the email address above and give the
project contributors a chance to resolve the vulnerability and issue a new
release prior to any public exposure; this helps protect the project's
users, and provides them with a chance to upgrade and/or update in order to
protect their applications.


## Policy

If we verify a reported security vulnerability, our policy is:

- We will patch the current release branch, as well as the immediate prior minor
release branch.

- After patching the release branches, we will immediately issue new security
fix releases for each patched release branch.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
},
"require-dev": {
"laminas/laminas-coding-standard": "^2.5",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^10.0",
"mikey179/vfsstream": "^1.6.7",
"phpunit/phpunit": "^10.5",
"vimeo/psalm": "^5.22"
},
"autoload": {
Expand Down
1 change: 1 addition & 0 deletions docs/book/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
../../README.md
76 changes: 76 additions & 0 deletions docs/book/v3/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Configuration

Register `dot-errorhandler` in you project by adding `Dot\ErrorHandler\ConfigProvider::class` to your configuration aggregator (to `config/config.php` for example),
and add `\Dot\ErrorHandler\ErrorHandlerInterface::class` (to `config/pipeline.php` for example) **as the outermost layer of the middleware** to catch all Exceptions

- Configure the error handler as shown below

config/autoload/error-handling.global.php

```php
<?php

use Dot\ErrorHandler\ErrorHandlerInterface;
use Dot\ErrorHandler\LogErrorHandler;
use Dot\ErrorHandler\ErrorHandler;

return [
'dependencies' => [
'aliases' => [
ErrorHandlerInterface::class => LogErrorHandler::class,
]

],
'dot-errorhandler' => [
'loggerEnabled' => true,
'logger' => 'dot-log.default_logger'
]
];
```

A configuration example for the default logger can be found in `config/log.global.php.dist`.

When declaring the `ErrorHandlerInterface` alias you can choose whether to log or not:

- for the simple Zend Expressive handler user `ErrorHandler`
- for logging use `LogErrorHandler`

The class `Dot\ErrorHandler\ErrorHandler` is the same as the Zend Expressive error handling class
the only difference being the removal of the `final` statement for making extension possible.

The class `Dot\ErrorHandler\LogErrorHandler` is `Dot\ErrorHandler\ErrorHandler` with
added logging support.

As a note: both `LogErrorHandler` and `ErrorHandler` have factories declared in the
package's `ConfigProvider`. If you need a custom ErrorHandler it must have a factory
declared in the config, as in the example.

Example:

```php
<?php

use Dot\ErrorHandler\ErrorHandlerInterface;
use Custom\MyErrorHandler;
use Custom\MyErrorHandlerFactory;


return [
'dependencies' => [
'factories' => [
MyErrorHandler::class => MyCustomHandlerFactory::class,
],

'aliases' => [
ErrorHandlerInterface::class => MyErrorHandler::class,
]

],
'dot-errorhandler' => [
'loggerEnabled' => true,
'logger' => 'dot-log.default_logger'
]
];
```

Config examples can be found in this project's `config` directory.
5 changes: 5 additions & 0 deletions docs/book/v3/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Installation

Install `dotkernel/dot-errorhandler` by executing the following Composer command:

composer require dotkernel/dot-errorhandler
6 changes: 6 additions & 0 deletions docs/book/v3/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Overview

`dot-errorhandler` is DotKernel's logging error handler, providing two options:

- `Dot\ErrorHandler\ErrorHandler`, same as the Zend Expressive error handling class with the only difference being the removal of the `final` statement for making extension possible
- `Dot\ErrorHandler\LogErrorHandler` adds logging support to the default `ErrorHandler` class
Loading

0 comments on commit 1d1c9ef

Please sign in to comment.