RalfEggert/zend-expressive-tutorial

Default router selection

Closed this issue · 13 comments

I'm reading through part 1, and I have a couple of differences of opinion immediately — this is not a reflection on the work you've done, but more a question of philosophy.

In the tutorial, you're suggesting using the zend-mvc router, and the zend-view renderer. Interestingly, our default suggestions are not either of these, but rather FastRoute and Plates, respectively.

The reasons for our current defaults are several:

  • FastRoute was chosen:
    • because it's the fastest of the three (based on many, many benchmarks).
    • because it defines constraints directly in the routing definition (vs. as additional configuration); we've found this is simpler to configure, and also makes understanding what makes a valid route match far easier.
  • Plates was chosen:
    • because it's the fastest of the three (based on quite a few benchmarks; this is even true when Twig's caching is in place!).
    • it uses plain old PHP for templating (just like zend-view).
    • great documentation.

Additionally, one goal of Expressive has been to showcase that choosing it does not tie developers to Zend Framework components. Developers can choose the technologies that fit their project and/or team expertise. In some cases, that might be a Zend component (for example, I can definitely see a case for using zend-inputfilter or zend-form!); in other cases, we might want to choose something outside the ZF ecosystem.

As such, as I review, I would like to submit pull requests that update the code and content to use the defaults we recommend. Are you okay with that?

The one area I see this being more difficult would be around forms, and I'm assuming you likely are using forms in this tutorial. zend-inputfilter was designed in part to provide a way to process form data without having ties to zend-view, however, so we have a potential way to handle that. If de-coupling proves too difficult, I'll reverse course and revert back to your original choices. However, I'd really like to see if we can accomplish this.

@weierophinney Interesting points. Are they also in the zend-expressive docs?

The one area I see this being more difficult would be around forms, and I'm assuming you likely are using forms in this tutorial. zend-inputfilter was designed in part to provide a way to process form data without having ties to zend-view, however, so we have a potential way to handle that. If de-coupling proves too difficult, I'll reverse course and revert back to your original choices. However, I'd really like to see if we can accomplish this.

You can easily use zend-inputfilter. I've been playing with an idea from @Ocramius to build a html form validator. It's based on zend-inputfilter, however some parts I had to hack to get it working with servicemanager 3.

Besides that, you have used a stand alone zend-inputfilter yourself on mwop.net :) If you go this route and create a custom InputFilter, it's even working with servicemanager 3.

@weierophinney

Just a quick note since I need to leave my office now for the whole day.

The idea was to show the flexibility of Zend\Expressive by providing two flavours for the tutorial. One which basically uses all the Zend components, and one which uses all the other great tools like Plates, FastRoute and Doctrine.

My tutorial so far is the Zend components based one.

I'll come back here later.

@RalfEggert Aha! I wasn't clear on that at all!

Here's my idea, then:

  • I'll continue reviewing chapters, but without component changes. I'll create an alternate PR based off of #16 that does exactly that, and continue from there.
  • In parallel, for each chapter, I'll provide a PR that updates the chapter to use the default/recommended components and/or 3rd party components (such as Doctrine). I may need assistance with using Doctrine and/or DBAL, but I can definitely tackle the bits and pieces around FastRoute and Plates. We can use these PRs as a jump-start on the second tutorial flavor.

Sound good?

Sounds good. Though I am not quite sure how to handle the PRs for the second tutorial flavor.

@weierophinney

I merged your PRs except the #17 since I am not sure how to handle that. I also added the short tags in the templates in all the parts.

Oh, and I added the docs for part2 in part1 branch as well.

Regarding the Doctrine stuff, maybe @codeliner or @xtreamwayz might be able to help?

@RalfEggert What do you need, all zend-db related stuff converted to doctrine?

@xtreamwayz

Well, yes. @weierophinney is working on the second flavour for the tutorial which will work with Plates, FastRoute and Doctrine. See his comment #15 (comment)

Maybe it makes sense, that Matthew finishes the work on the Plates and FastRoute stuff and then someone takes over for Doctrine?

Yeah that makes sense.

@xtreamwayz Would be great if you can take over the Doctrine part. Unfortunately, my time is very limited these days. However, if it is not possible for you let me know and I'll find a way to take over Doctrine.

I will close this now. I think we should finish up this tutorial first before we add a second flavor of it.