Skip to content

Commit 1fd8a5a

Browse files
committed
Merge branch 'migrate-laminas'
* migrate-laminas: 100% tweak test alias Zend\Stdlib\AbstractOptions package name fix some autoload hacks clean up migrate to laminas
2 parents 0435879 + f73ae66 commit 1fd8a5a

File tree

65 files changed

+704
-597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+704
-597
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CONTRIBUTING
33
To contribute, you can send pull requests with :
44

55
- Typo fix.
6-
- Use [Zend Coding Standard](https://github.com/zendframework/zend-coding-standard).
6+
- Use [Laminas Coding Standard](https://github.com/laminas/laminas-coding-standard).
77
- patch(es) need new/updated test(s).
88
- new feature(s) need test(s).
99

README.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ ErrorHeroModule
77
[![PHPStan](https://img.shields.io/badge/style-level%20max-brightgreen.svg?style=flat-square&label=phpstan)](https://github.com/phpstan/phpstan)
88
[![Downloads](https://poser.pugx.org/samsonasik/error-hero-module/downloads)](https://packagist.org/packages/samsonasik/error-hero-module)
99

10-
> This is README for version ^2.0 which only support ZF3 and ZF Expressive version 3 with php ^7.1.
10+
> This is README for version ^3.0 which only support Laminas Mvc version 3 and Mezzio version 3 with php ^7.1.
1111
12-
> For version 1, you can read at [version 1 readme](https://github.com/samsonasik/ErrorHeroModule/tree/1.x.x) which still support ZF2 and ZF Expressive version 1 and 2 with php ^5.6|^7.0 support.
12+
> For version ^2.0, you can read at [version 2 readme](https://github.com/samsonasik/ErrorHeroModule/tree/2.x.x) which only support ZF3 and ZF Expressive version 3 with php ^7.1.
13+
14+
> For version 1, you can read at [version 1 readme](https://github.com/samsonasik/ErrorHeroModule/tree/1.x.x) which still support ZF2 and ZF Mezzio version 1 and 2 with php ^5.6|^7.0 support.
1315
1416
Introduction
1517
------------
1618

17-
ErrorHeroModule is a module for Error Logging (DB and Mail) your ZF3 Mvc Application, and ZF Expressive for Exceptions in 'dispatch.error' or 'render.error' or during request and response, and [PHP E_* Error](http://www.php.net/manual/en/errorfunc.constants.php).
19+
ErrorHeroModule is a module for Error Logging (DB and Mail) your Laminas Mvc 3 Application, and Mezzio 3 for Exceptions in 'dispatch.error' or 'render.error' or during request and response, and [PHP E_* Error](http://www.php.net/manual/en/errorfunc.constants.php).
1820

1921
Features
2022
--------
@@ -26,7 +28,7 @@ Features
2628
- [x] Handle only once log error for same error per configured time range.
2729
- [x] Set default page (web access) or default message (console access) for error if configured 'display_errors' = 0.
2830
- [x] Set default content when request is XMLHttpRequest via 'ajax' configuration.
29-
- [x] Set default content when there is [no template service](https://github.com/zendframework/zend-expressive-template/blob/9b6c2e06f8c1d7e43750f72b64cc749552f2bdbe/src/TemplateRendererInterface.php) via 'no_template' configuration (ZF Expressive 3).
31+
- [x] Set default content when there is [no template service](https://github.com/mezzio/mezzio-template/blob/9b6c2e06f8c1d7e43750f72b64cc749552f2bdbe/src/TemplateRendererInterface.php) via 'no_template' configuration (Mezzio 3).
3032
- [x] Provide request information ( http method, raw data, body data, query data, files data, cookie data, and ip address).
3133
- [x] Send Mail
3234
- [x] many receivers to listed configured email
@@ -55,9 +57,9 @@ CREATE TABLE `log` (
5557
```
5658
> If you use other RDBMS, you may follow the `log` table structure above.
5759
58-
**2. Setup your Zend\Db\Adapter\AdapterInterface service or your Doctrine\ORM\EntityManager service config**
60+
**2. Setup your Laminas\Db\Adapter\AdapterInterface service or your Doctrine\ORM\EntityManager service config**
5961

60-
You can use 'db' (with _Zend\Db_) config or 'doctrine' (with _DoctrineORMModule_) config that will be transformed to be usable with `Zend\Log\Writer\Db`.
62+
You can use 'db' (with _Laminas\Db_) config or 'doctrine' (with _DoctrineORMModule_) config that will be transformed to be usable with `Laminas\Log\Writer\Db`.
6163

6264
```php
6365
<?php
@@ -112,7 +114,7 @@ composer require samsonasik/error-hero-module
112114

113115
**4. Copy config**
114116

115-
***a. For [ZF3 Mvc](https://zendframework.github.io/tutorials/getting-started/overview/) application, copy `error-hero-module.local.php.dist` config to your local's autoload and configure it***
117+
***a. For [Laminas Mvc](https://docs.laminas.dev/tutorials/getting-started/overview/) application, copy `error-hero-module.local.php.dist` config to your local's autoload and configure it***
116118

117119
| source | destination |
118120
|------------------------------------------------------------------------------|---------------------------------------------|
@@ -124,25 +126,25 @@ Or run copy command:
124126
cp vendor/samsonasik/error-hero-module/config/error-hero-module.local.php.dist config/autoload/error-hero-module.local.php
125127
```
126128

127-
***b. For [ZF Expressive](https://zendframework.github.io/zend-expressive/) application, copy `expressive-error-hero-module.local.php.dist` config to your local's autoload and configure it***
129+
***b. For [Mezzio](https://docs.mezzio.dev/mezzio/) application, copy `mezzio-error-hero-module.local.php.dist` config to your local's autoload and configure it***
128130

129131
| source | destination |
130132
|-----------------------------------------------------------------------------------------|--------------------------------------------------------|
131-
| vendor/samsonasik/error-hero-module/config/expressive-error-hero-module.local.php.dist | config/autoload/expressive-error-hero-module.local.php |
133+
| vendor/samsonasik/error-hero-module/config/mezzio-error-hero-module.local.php.dist | config/autoload/mezzio-error-hero-module.local.php |
132134

133135
Or run copy command:
134136

135137
```sh
136-
cp vendor/samsonasik/error-hero-module/config/expressive-error-hero-module.local.php.dist config/autoload/expressive-error-hero-module.local.php
138+
cp vendor/samsonasik/error-hero-module/config/mezzio-error-hero-module.local.php.dist config/autoload/mezzio-error-hero-module.local.php
137139
```
138140

139141
When done, you can modify logger service named `ErrorHeroModuleLogger` and `error-hero-module` config in your's local config:
140142

141143
```php
142144
<?php
143-
// config/autoload/error-hero-module.local.php or config/autoload/expressive-error-hero-module.local.php
145+
// config/autoload/error-hero-module.local.php or config/autoload/Mezzio-error-hero-module.local.php
144146

145-
use Zend\Db\Adapter\AdapterInterface;
147+
use Laminas\Db\Adapter\AdapterInterface;
146148

147149
return [
148150

@@ -190,7 +192,7 @@ return [
190192
// 2. error-preview command (ErrorHeroModule\Controller\ErrorPreviewConsoleController) via
191193
// php public/index.php error-preview
192194
//
193-
// for zf-expressive ^3.0.0, the disable error-preview page is by unregister 'error-preview' from config/routes
195+
// for Mezzio ^3.0.0, the disable error-preview page is by unregister 'error-preview' from config/routes
194196
//
195197
//
196198
// otherwise(false), you can't see them, eg: on production env.
@@ -228,13 +230,13 @@ return [
228230

229231
// if enable and display_errors = 0, the page will bring layout and view
230232
'template' => [
231-
// non zend-view (plates, twig) for expressive not need a layout definition
233+
// non laminas-view (plates, twig) for Mezzio not need a layout definition
232234
// as layout defined in the view
233235
'layout' => 'layout/layout',
234236
'view' => 'error-hero-module/error-default'
235237
],
236238

237-
// for expressive, when container doesn't has \Zend\Expressive\Template\TemplateRendererInterface service
239+
// for Mezzio, when container doesn't has \Mezzio\Template\TemplateRendererInterface service
238240
// if enable, and display_errors = 0, then show a message under no_template config
239241
'no_template' => [
240242
'message' => <<<json
@@ -247,7 +249,7 @@ return [
247249
json
248250
],
249251

250-
// if enable and display_errors = 0, the console will bring message for zend-mvc
252+
// if enable and display_errors = 0, the console will bring message for laminas-mvc
251253
'console' => [
252254
'message' => 'We have encountered a problem and we can not fulfill your request. An error report has been generated and sent to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.',
253255
],
@@ -275,10 +277,10 @@ json
275277
// set to true to activate email notification on log error event
276278
'enable' => false,
277279

278-
// Zend\Mail\Message instance registered at service manager
280+
// Laminas\Mail\Message instance registered at service manager
279281
'mail-message' => 'YourMailMessageService',
280282

281-
// Zend\Mail\Transport\TransportInterface instance registered at service manager
283+
// Laminas\Mail\Transport\TransportInterface instance registered at service manager
282284
'mail-transport' => 'YourMailTransportService',
283285

284286
// email sender
@@ -296,7 +298,7 @@ json
296298

297299
**5. Lastly, enable it**
298300

299-
***a. For ZF Mvc application***
301+
***a. For Laminas Mvc application***
300302

301303
```php
302304
// config/modules.config.php or config/application.config.php
@@ -306,21 +308,21 @@ return [
306308
],
307309
```
308310

309-
***b. For ZF Expressive application***
311+
***b. For Mezzio application***
310312

311-
> You need to use Zend\ServiceManager for service container and Zend\View for template engine.
313+
> You need to use Laminas\ServiceManager for service container and Laminas\View for template engine.
312314

313-
For [zend-expressive-skeleton](https://github.com/zendframework/zend-expressive-skeleton) ^3.0.0, you need to open `config/pipeline.php` and add the `ErrorHeroModule\Middleware\Expressive::class` middleware after default `ErrorHandler::class` registration:
315+
For [laminas-Mezzio-skeleton](https://github.com/mezzio/mezzio-skeleton) ^3.0.0, you need to open `config/pipeline.php` and add the `ErrorHeroModule\Middleware\Mezzio::class` middleware after default `ErrorHandler::class` registration:
314316

315317
```php
316318
$app->pipe(ErrorHandler::class);
317-
$app->pipe(ErrorHeroModule\Middleware\Expressive::class); // here
319+
$app->pipe(ErrorHeroModule\Middleware\Mezzio::class); // here
318320
```
319321

320322
and also add `error-preview` routes in `config/routes.php` (optional) :
321323

322324
```php
323-
// for use zend-router
325+
// for use laminas-router
324326
$app->get('/error-preview[/:action]', ErrorHeroModule\Middleware\Routed\Preview\ErrorPreviewAction::class, 'error-preview');
325327

326328
// for use FastRoute
@@ -337,10 +339,10 @@ _**Web Access**_
337339

338340
| URl | Preview For |
339341
|---------------------------------------|-----------------|
340-
| http://yourzfapp/error-preview | Exception |
341-
| http://yourzfapp/error-preview/error | Error |
342-
| http://yourzfapp/error-preview/notice | PHP E_NOTICE |
343-
| http://yourzfapp/error-preview/fatal | PHP Fatal Error |
342+
| http://yourlaminasormezzioapp/error-preview | Exception |
343+
| http://yourlaminasormezzioapp/error-preview/error | Error |
344+
| http://yourlaminasormezzioapp/error-preview/notice | PHP E_NOTICE |
345+
| http://yourlaminasormezzioapp/error-preview/fatal | PHP Fatal Error |
344346

345347
You will get the following page if display_errors config is 0:
346348

@@ -350,10 +352,10 @@ You will get the following page if display_errors config is 0:
350352
351353
_**Console Access**_
352354

353-
> If you use zend-mvc v3, you need to have `zendframework/zend-mvc-console` in your vendor, if you don't have, you can install it via command:
355+
> If you use laminas-mvc v3, you need to have `laminas/laminas-mvc-console` in your vendor, if you don't have, you can install it via command:
354356
355357
> ```sh
356-
> composer require zendframework/zend-mvc-console --sort-packages
358+
> composer require laminas/laminas-mvc-console --sort-packages
357359
> ```
358360
359361
| Command | Preview For |
@@ -368,7 +370,7 @@ You will get the following page if display_errors config is 0:
368370
369371
> For production env, you can disable error-preview sample page with set `['error-hero-module']['enable-error-preview-page']` to false.
370372
371-
> For ZF Expressive, there is no default console implementation, so, if you want to apply it in your console in ZF Expressive, you may need to custom implementation error handler that utilize `ErrorHeroModule\Handler\Logging` service (see detailed usage at `ErrorHeroModule\Middleware\Expressive` class)
373+
> For Mezzio, there is no default console implementation, so, if you want to apply it in your console in Mezzio, you may need to custom implementation error handler that utilize `ErrorHeroModule\Handler\Logging` service (see detailed usage at `ErrorHeroModule\Middleware\Mezzio` class)
372374
373375
Contributing
374376
------------

composer.json

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
22
"name": "samsonasik/error-hero-module",
33
"type": "library",
4-
"description": "A Hero for your Zend Framework application to trap php errors & exceptions",
4+
"description": "A Hero for your Laminas and Mezzio application to trap php errors & exceptions",
55
"keywords": [
6-
"zf2",
7-
"zf3",
6+
"laminas",
87
"error",
9-
"expressive",
8+
"mezzio",
109
"hero",
1110
"log",
1211
"logger",
@@ -19,7 +18,7 @@
1918
"psr7",
2019
"psr11",
2120
"psr15",
22-
"zend-view",
21+
"laminas-view",
2322
"twig",
2423
"plates",
2524
"symfony",
@@ -40,56 +39,58 @@
4039
],
4140
"require": {
4241
"php": "^7.1",
42+
"laminas/laminas-db": "^2.5",
43+
"laminas/laminas-diactoros": "^2.0",
44+
"laminas/laminas-log": "^2.10",
45+
"laminas/laminas-mail": "^2.9",
46+
"laminas/laminas-psr7bridge": "^1.1",
47+
"laminas/laminas-text": "^2.5",
48+
"laminas/laminas-uri": "^2.7",
4349
"psr/container": "^1.0",
4450
"seld/jsonlint": "^1.5",
45-
"webmozart/assert": "^1.4",
46-
"zendframework/zend-db": "^2.5",
47-
"zendframework/zend-diactoros": "^2.0",
48-
"zendframework/zend-log": "^2.10",
49-
"zendframework/zend-mail": "^2.9",
50-
"zendframework/zend-psr7bridge": "^1.1",
51-
"zendframework/zend-text": "^2.5",
52-
"zendframework/zend-uri": "^2.7"
51+
"webmozart/assert": "^1.4"
5352
},
5453
"conflict": {
5554
"doctrine/doctrine-orm-module": "<2.1",
5655
"elie29/zend-phpdi-config": "<4.0",
57-
"zendframework/zend-expressive": "<3.0 >=4.0",
58-
"zendframework/zend-mvc": "<3.0 >=4.0",
59-
"zendframework/zend-servicemanager": "<3.3"
56+
"laminas/laminas-mvc": "<3.0 >=4.0",
57+
"laminas/laminas-servicemanager": "<3.3",
58+
"mezzio/mezzio": "<3.0 >=4.0"
6059
},
6160
"require-dev": {
6261
"aura/di": "^3.4",
6362
"doctrine/doctrine-orm-module": "^2.1",
6463
"elie29/zend-phpdi-config": "^4.0",
6564
"kahlan/kahlan": "^4.6.4",
65+
"laminas/laminas-cache": "^2.9",
66+
"laminas/laminas-coding-standard": "^2.0",
67+
"laminas/laminas-form": "^2.14",
68+
"laminas/laminas-mvc": "^3.0",
69+
"laminas/laminas-mvc-console": "^1.1",
70+
"laminas/laminas-servicemanager": "^3.3",
71+
"mezzio/mezzio": "^3.0",
72+
"mezzio/mezzio-laminasviewrenderer": "^2.0",
6673
"northwoods/container": "^3.0",
6774
"php-coveralls/php-coveralls": "^2.0",
6875
"php-di/php-di": "^6.0",
6976
"phpstan/phpstan": "^0.10",
7077
"phpstan/phpstan-webmozart-assert": "^0.10.0",
7178
"pimple/pimple": "^3.2",
7279
"squizlabs/php_codesniffer": "3.5.3 as 2.7",
73-
"symfony/dependency-injection": "^4.0",
74-
"zendframework/zend-coding-standard": "^1.0",
75-
"zendframework/zend-expressive": "^3.0",
76-
"zendframework/zend-expressive-zendviewrenderer": "^2.0",
77-
"zendframework/zend-mvc": "^3.0",
78-
"zendframework/zend-mvc-console": "^1.1",
79-
"zendframework/zend-servicemanager": "^3.3"
80+
"symfony/dependency-injection": "^4.0"
8081
},
8182
"suggest": {
82-
"zendframework/zend-expressive-platesrenderer": "^2.0 to be able to use plates template engine in zend-expressive ^3.0",
83-
"zendframework/zend-expressive-twigrenderer": "^2.0 to be able to use twig template engine in zend-expressive ^3.0",
84-
"zendframework/zend-expressive-zendviewrenderer": "^2.0 to be able to use zend-view template engine in zend-expressive ^3.0",
85-
"zendframework/zend-mvc-console": "^1.1 for zend-mvc ^3.0 usage to be able to use Console Controller"
83+
"laminas/laminas-mvc-console": "^1.1 for laminas-mvc ^3.0 usage to be able to use Console Controller",
84+
"mezzio/mezzio-laminasviewrenderer": "^2.0 to be able to use laminas-view template engine in mezzio ^3.0",
85+
"mezzio/mezzio-platesrenderer": "^2.0 to be able to use plates template engine in mezzio ^3.0",
86+
"mezzio/mezzio-twigrenderer": "^2.0 to be able to use twig template engine in mezzio ^3.0"
8687
},
8788
"config": {
8889
"bin-dir": "bin",
8990
"sort-packages": true
9091
},
9192
"extra": {
92-
"zf": {
93+
"laminas": {
9394
"module": "ErrorHeroModule"
9495
}
9596
},
@@ -106,6 +107,8 @@
106107
"ErrorHeroModule\\Spec\\": "spec/"
107108
}
108109
},
110+
"minimum-stability": "dev",
111+
"prefer-stable": true,
109112
"scripts": {
110113
"cs-check": "phpcs",
111114
"cs-fix": "phpcbf"

config/error-hero-module.local.php.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
use Zend\Db\Adapter\AdapterInterface;
3+
use Laminas\Db\Adapter\AdapterInterface;
44

55
return [
66

@@ -115,10 +115,10 @@ json
115115
// set to true to activate email notification on log error
116116
'enable' => false,
117117

118-
// Zend\Mail\Message instance registered at service manager
118+
// Laminas\Mail\Message instance registered at service manager
119119
'mail-message' => 'YourMailMessageService',
120120

121-
// Zend\Mail\Transport\TransportInterface instance registered at service manager
121+
// Laminas\Mail\Transport\TransportInterface instance registered at service manager
122122
'mail-transport' => 'YourMailTransportService',
123123

124124
// email sender

config/expressive-error-hero-module.local.php.dist renamed to config/mezzio-error-hero-module.local.php.dist

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace ErrorHeroModule;
44

5-
use Zend\Db\Adapter\AdapterInterface;
6-
use Zend\Log;
7-
use Zend\ServiceManager\Factory\InvokableFactory;
5+
use Laminas\Db\Adapter\AdapterInterface;
6+
use Laminas\Log;
7+
use Laminas\ServiceManager\Factory\InvokableFactory;
88

99
return [
1010

@@ -84,7 +84,7 @@ return [
8484
'view' => 'error-hero-module::error-default'
8585
],
8686

87-
// for expressive, when container doesn't has \Zend\Expressive\Template\TemplateRendererInterface service
87+
// for Mezzio, when container doesn't has \Mezzio\Template\TemplateRendererInterface service
8888
// if enable, and display_errors = 0, then show a message under no_template config
8989
'no_template' => [
9090
'message' => <<<json
@@ -120,10 +120,10 @@ json
120120
// set to true to activate email notification on log error
121121
'enable' => false,
122122

123-
// Zend\Mail\Message instance registered at service manager
123+
// Laminas\Mail\Message instance registered at service manager
124124
'mail-message' => 'YourMailMessageService',
125125

126-
// Zend\Mail\Transport\TransportInterface instance registered at service manager
126+
// Laminas\Mail\Transport\TransportInterface instance registered at service manager
127127
'mail-transport' => 'YourMailTransportService',
128128

129129
// email sender
@@ -141,7 +141,7 @@ json
141141
Log\LoggerAbstractServiceFactory::class,
142142
],
143143
'factories' => [
144-
Middleware\Expressive::class => Middleware\ExpressiveFactory::class,
144+
Middleware\Mezzio::class => Middleware\MezzioFactory::class,
145145
ErrorHeroModule\Middleware\Routed\Preview\ErrorPreviewAction::class => InvokableFactory::class,
146146

147147
Handler\Logging::class => Handler\LoggingFactory::class,

0 commit comments

Comments
 (0)