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
120 stars 31 forks source link

The default value in the installer causes a rendering error. #49

Closed smj320 closed 3 years ago

smj320 commented 3 years ago

Bug Report

Version 3.9.x

Windows 10, PHP7.4 Composer version 2.0.9

Summary

When I installed it as default, I met a rendering error.

Current behavior

When I install it as default, the choice of template engine is "no template engine[n]".

  Which template engine do you want to use?
  [1] Plates (supported by laminas)
  [2] Twig (supported by laminas)
  [3] laminas-view installs laminas-servicemanager (supported by laminas)
  [n] None of the above  <<< here
  Make your selection or type a composer package name and version (n):

Tracing the tutorial and access localhost:8080, I met a rendering error.

01

When I choice laminas-view[3], localhost:8080 successfully show the demonstration page. And when I chose [2], I had to install a twigrenderer and create template directires additionally .

How to reproduce

composer create-project mezzio/mezzio-skeleton mezzio

Install using default value.

composer run server --timetout=0

and access http://localhost:8080

My result was

  What type of installation would you like?
  [1] Minimal (no default middleware, templates, or assets; configuration only)
  [2] Flat (flat source code structure; default selection) <<<here
  [3] Modular (modular source code structure; recommended)
  Make your selection (2):

  Which container do you want to use for dependency injection?
  [1] Aura.Di (supported by laminas)
  [2] Pimple (supported by laminas)
  [3] laminas-servicemanager (supported by laminas) <<< here
  [4] Auryn
  [5] Symfony DI Container
  [6] PHP-DI
  [7] chubbyphp-container
  Make your selection or type a composer package name and version (laminas-servicemanager (supported by laminas)):

  Which router do you want to use?
  [1] Aura.Router (supported by laminas)
  [2] FastRoute (supported by laminas) <<<here
  [3] laminas-router (supported by laminas)
  Make your selection or type a composer package name and version (FastRoute (supported by laminas)):

  Which template engine do you want to use?
  [1] Plates (supported by laminas)
  [2] Twig (supported by laminas)
  [3] laminas-view installs laminas-servicemanager (supported by laminas)
  [n] None of the above  <<<here
  Make your selection or type a composer package name and version (n):

  Which error handler do you want to use during development?
  [1] Whoops (supported by laminas)  <<<here
  [n] None of the above
  Make your selection or type a composer package name and version (Whoops (supported by laminas)):

  Please select which config file you wish to inject 'Laminas\Validator\ConfigProvider' into:
  [0] Do not inject
  [1] config/config.php  <<<here
  Make your selection (default is 1):

  Remember this option for other packages of the same type? (Y/n)

Expected behavior

I think this behavior will surprise beginners (me too) and It leads to giving up on the choice of mezzio.

So please consider to change the default value to [3], if you can.

And also consider improving [2] to install twigrenderer and create directories automatically.

geerteltink commented 3 years ago

This is not a bug really. This is desired behavior. If you use mezzio for api's you don't need a template renderer. Since the template renderer is optional, we also don't want to select or force one by default.

If you read the first section of the tutorial carefully we also mention this here: https://docs.mezzio.dev/mezzio/v3/getting-started/quick-start/#create-a-new-project

A template renderer. You can ignore this when creating an API project, but if you will be creating any HTML pages, we recommend installing one. We prefer Plates.

This is different for the router and container because you always need one with mezzio.

The whoops error handler is debatable, because you don't need it but it is very easy to debug during development. Besides that, it is switched off for production environments.

froschdesign commented 3 years ago

@geerteltink

This is not a bug really.

Are you sure? If no template renderer is installed then the following must work:

https://github.com/mezzio/mezzio-skeleton/blob/f2d6a431d71b6560b9925ccd914d792627e38b7b/src/App/src/Handler/HomePageHandler.php#L91-L96

But something doesn't seem to be working here.