|
| 1 | +# Should You Choose zend-expressive Over zend-mvc? |
| 2 | + |
| 3 | +We recommend that you choose Expressive for any new project — _if the |
| 4 | +choice is yours to make_. |
| 5 | + |
| 6 | +## Why Use zend-mvc? |
| 7 | + |
| 8 | +zend-mvc is a proven platform, with half a decade of development behind it. It |
| 9 | +is stable and battle-tested in production platforms. |
| 10 | + |
| 11 | +Because it is opinionated about project structure and architecture, fewer |
| 12 | +decisions need be made up front; developers know where new code goes, and how it |
| 13 | +will wire into the overall application. |
| 14 | + |
| 15 | +Additionally, a number of training courses exist, including [offerings by |
| 16 | +Zend](http://www.zend.com/en/services/training/zf-fundamentals-i), allowing you |
| 17 | +or your team to fully learn the framework and take advantage of all its features. |
| 18 | + |
| 19 | +Finally, zend-mvc has a lively [module ecosystem](https://packagist.org/search/?q=zf2), |
| 20 | +allowing you to add features and capabilities to your application without |
| 21 | +needing to develop them from scratch. |
| 22 | + |
| 23 | +## We Recommend Expressive |
| 24 | + |
| 25 | +[zend-mvc](https://github.com/zendframework/zend-mvc) has many preconceptions |
| 26 | +about how things work, yet they're very broad and general. What’s more, it |
| 27 | +also has several pre-wired structures in place that may either aid you — |
| 28 | +or get in your way. |
| 29 | + |
| 30 | +As a result, you are required to know a lot of what those things are — *if* you |
| 31 | +want to use it optimally. And to acquire that depth of knowledge, you’re going |
| 32 | +to need to spend a lot of time digging deep into zend-mvc’s internals before |
| 33 | +you begin to get the most out of it. |
| 34 | + |
| 35 | +To quote Zend Framework project lead, [Matthew Weier O’Phinney](https://mwop.net): |
| 36 | + |
| 37 | +> The problem is that zend-mvc is anything but beginner-friendly at this point. |
| 38 | +> You're required to deep dive into the event manager, service manager, and |
| 39 | +> module system — right from the outset; And to do this you need more than a |
| 40 | +> passing understanding of object-oriented programming and a range of design |
| 41 | +> patterns. |
| 42 | +
|
| 43 | +Expressive (specifically applications based on |
| 44 | +[the Expressive Skeleton Installer](https://docs.zendframework.com/zend-expressive/getting-started/skeleton/)) |
| 45 | +on the other hand, comes with barely any of these assumptions and requirements. |
| 46 | + |
| 47 | +It provides a very minimalist structure. Essentially all you have to become |
| 48 | +familiar with are five core components. These are: |
| 49 | + |
| 50 | +- A DI container. |
| 51 | +- A router. |
| 52 | +- An error handler for development. |
| 53 | +- A template engine (if you’re not creating an API). |
| 54 | +- PSR-7 messages and http-interop (future PSR-15) middleware. |
| 55 | + |
| 56 | +In many cases, these are provided for you by the skeleton, and do not require |
| 57 | +any additional knowledge on your part. Given that, you can quickly get up to |
| 58 | +speed with the framework and begin creating the application that you need. We |
| 59 | +believe that this approach — in contrast to the zend-mvc approach — |
| 60 | +is more flexible and accommodating. |
| 61 | + |
| 62 | +What’s more, you can mix and match the types of applications that you create. |
| 63 | + |
| 64 | +- Do you just need an API? Great; you can do that quite quickly. |
| 65 | +- Do you want an HTML-based front-end? That’s available too. |
| 66 | + |
| 67 | +When building applications with Expressive, you can make use of the various Zend |
| 68 | +components, or any third-party components or middleware. You can pick and |
| 69 | +choose what you need, as and when you need it. You’re not bound by many, if |
| 70 | +any, constraints and design decisions. |
| 71 | + |
| 72 | +## In Conclusion |
| 73 | + |
| 74 | +For what it’s worth, we’re **not** saying that zend-mvc is a poor choice! What |
| 75 | +we are saying is: |
| 76 | + |
| 77 | +1. The learning curve, from getting started to building the first application, |
| 78 | + is _significantly_ lower with Expressive |
| 79 | +2. The ways in which you can create applications, whether through multiple |
| 80 | + pieces of middleware or by combining multiple Expressive apps, into one |
| 81 | + larger one, is a much more efficient and fluid way to work |
| 82 | + |
| 83 | +Ultimately, the choice is always up to you, your team, and your project’s needs. |
| 84 | +We just want to ensure that you’ve got all the information you need, to make an |
| 85 | +informed decision. |
0 commit comments