Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from davidyell/error-handler-middleware
Browse files Browse the repository at this point in the history
Error handler middleware
  • Loading branch information
davidyell authored Oct 15, 2018
2 parents 90fabe4 + 742994a commit ea0231a
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 149 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
language: php

php:
- 7.1
- 7.2

sudo: false
Expand All @@ -15,13 +14,13 @@ matrix:
fast_finish: true

include:
- php: 7.1
- php: 7.2
env: DEFAULT=1

- php: 7.1
- php: 7.2
env: PHPCS=1 DEFAULT=0

- php: 7.1
- php: 7.2
env: COVERALLS=1 DEFAULT=0

install:
Expand Down
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ data into the view variables.
I found that by containing all the functionality for SEO inside a component it makes it easier to manage.

# Requirements
* CakePHP 3.4+
* PHP 7.1+
* CakePHP 3.6+
* PHP 7.2+

# Installation
[https://packagist.org/packages/davidyell/seo](https://packagist.org/packages/davidyell/seo)
Expand Down Expand Up @@ -92,4 +92,21 @@ Don't forget that you can set the config directly on an instance of the componen
// ExamplesController.php

$this->components()->get('Seo')->setConfig('fields.title', 'My new title');
```
```

# Error handler middleware
It is very helpful to be able to catch 404 errors and use them to manage your SEO redirecting. This allows for only urls
which do not match your application to be redirecting, avoiding any overhead.

The plugin provides a basic middleware for this purpose which can be implemented into your `/src/Application.php`

```
$this->redirects = [
'/examples/first-example' => [
'target' => '/tutorials/first',
'code' => 301
]
];
$queue->add(new \Seo\Error\Middleware\ErrorHandlerMiddleware($this->redirects))
```

7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
}
],
"require": {
"php": ">=7.1",
"cakephp/cakephp": "~3.4"
"php": ">=7.2",
"cakephp/cakephp": "~3.6",
"davidyell/seo-redirector": "^0"
},
"require-dev": {
"phpunit/phpunit": "*",
"phpunit/phpunit": "^5.7.14|^6.0",
"cakephp/cakephp-codesniffer": "~3.0",
"satooshi/php-coveralls": "^2.0"
},
Expand Down
Loading

0 comments on commit ea0231a

Please sign in to comment.