mezzio / mezzio-skeleton

Laminas mezzio skeleton. Begin developing PSR-15 middleware applications in seconds!
https://docs.mezzio.dev/mezzio/
BSD 3-Clause "New" or "Revised" License
117 stars 31 forks source link

500 error encountered when adding to routes.php. #65

Closed junobartowski closed 2 years ago

junobartowski commented 2 years ago

Bug Report

I created an application with the following options:

composer create-project mezzio/mezzio-skeleton mezzio

After creating the application, I ran composer run --timeout=0 serve. When the application is running, I ran composer mezzio mezzio:module:create User and the user is then created without errors. I registered it using composer mezzio mezzio:module:register User and created the handler using composer mezzio mezzio:handler:create "User\Handler\RegisterHandler". No errors as well. So I continued adding the signup on the config/routes.php, $app->route('/signup', \User\Handler\RegisterHandler::class, ['GET', 'POST'], 'signup');.

After visiting the application, this is what I got:

Current behavior

image

Expected behavior

I am expecting to see the text Template for User\Handler\RegisterHandler but it displays 500 error without an explanation. It is just something like this:

image
froschdesign commented 2 years ago

@junobartowski

…it displays 500 error without an explanation.

Try to enable Whoops: https://docs.mezzio.dev/mezzio/v3/features/error-handling/#use-development-mode-configuration-to-enable-whoops

junobartowski commented 2 years ago

@froschdesign Thank you for the quick response. I was able to get the error now:

Fatal error: Uncaught Laminas\ConfigAggregator\InvalidConfigProviderException: Cannot read config from Signup\ConfigProvider - class cannot be loaded. in /Documents/mezzio/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php:19 Stack trace: #0 /Documents/mezzio/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(106): Laminas\ConfigAggregator\InvalidConfigProviderException::fromNamedProvider('Signup\ConfigPr...') #1 /Documents/mezzio/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(220): Laminas\ConfigAggregator\ConfigAggregator->resolveProvider('Signup\ConfigPr...') #2 /Documents/mezzio/mezzio/vendor/laminas/laminas-config-aggregator/src/ConfigAggregator.php(75): Laminas\ConfigAggregator\ConfigAggregator->loadConfigFromProviders(Array) #3 /Documents/mezzio/mezzio/config/config.php(51): Laminas\ConfigAggregator\ConfigAggregator->__construct(Array, 'data/cache/conf...') #4 /Documents/mezzio/mezzio/config/container.php(8): require('/...') #5 /Documents/mezzio/mezzio/public/index.php(18): require('/...') #6 /Documents/mezzio/mezzio/public/index.php(30): {closure}() #7 {main} thrown in /Documents/mezzio/mezzio/vendor/laminas/laminas-config-aggregator/src/InvalidConfigProviderException.php on line 19

I am new to Mezzio and still trying to learn.

junobartowski commented 2 years ago

This is the structure:

image
froschdesign commented 2 years ago

The config provider of your User module is not the problem but there is config provider registered for Signup:

Cannot read config from Signup\ConfigProvider - class cannot be loaded.

Please check the file config/config.php and search for Signup\ConfigProvider::class and remove it. Did you have a module called "Signup" before?

junobartowski commented 2 years ago

Yes it was a module I deleted a while ago. I removed it on the config and now this error shows on the file I haven't modified:

Too few arguments to function User\Handler\RegisterHandler::__construct(), 1 passed in /Documents/mezzio/mezzio/src/User/src/Handler/RegisterHandlerFactory.php on line 14 and exactly 2 expected

junobartowski commented 2 years ago

Its the RegisterHandler I modified not the RegisterHandlerFactory which got affected. It is showing now. We can now close this. Thank you very much for the quick help.

image
froschdesign commented 2 years ago

@junobartowski If you need further help, use our forums: https://discourse.laminas.dev