What is Zend Expressive and Zend MVC? - php

I am starting a new project in PHP and wanted to choose the latest ZendFramework. I see that Zend Framework 3 has been released so I wanted to start with Zend Framework 3 itself. But when I go to the INSTALL page of Zend, they have given options as Zend MVC and Zend expressive.
I read about them and have an understanding that Expressive is a microframework while MVC is a full-stack framework. Apart from this I am not very clear about them.
I see that Zend MVC was also there for ZF2 and the documentation says MVC as a layer. I could not find Expressive for zf2 though.
Question:
Are both Zend MVC and Zend Expressive packages? and are part of zf3?
When I see the installed packages in Zend MVC and Zend Expressive, I don't see a package for Zend framework, but I see separate packages for Zend Components such as zend-http, zend-json, etc. So are these (expressive and MVC) just built over different Zend components?
How do I know that I am using ZF3?

Are both Zend MVC and Zend Expressive packages? and are part of zf3?
This depends a bit on your definition of "packages". Zend Expressive is not part of ZF3, it is a microframework alternative to ZF3. Zend MVC and Zend Expressive are both packages, and they also depend on other packages. ZF3 is what is known as a "meta package", which means it doesn't have any code of its own, it is soley a collection of other packages. The ZF3 meta package includes the Zend MVC package.
are these (expressive and MVC) just built over different Zend components?
Yes, and there is quite a bit of overlap.
How do I know that I am using ZF3?
This is more a question of semantics. If you have the Zend Framework meta package installed, that's ZF3. If you were just using the MVC package, you could argue that's still ZF3. If you are using Expressive, that's something else.
The line between ZF3 and Expressive (and when you would use one over the other) is somewhat fuzzy. This discussion may help you.
In an earlier edit you asked which you should use to create a REST API. You could do that with either.

Related

Zend_Di (Zend 2.0 beta) and Zend Framework 1.11

I was wondering if any one had any kind of success integrating a Zend Framework 2.0 beta in a Zend Framework 1.11 project.
I am currently building a project using ZF 1.11. I don't want to use ZF 2.0 yet since they say on the developpers blog that backward compatibility isn't guaranteed. The project developpement will span over a few months and I don't want to fix a lot of stuff when I update to the newest release (which will resolve bugs and vulnerabilities).
Is there a quick tutorial, or did anybody include a Zend Framework 2.0 module (using PHP namespaces) in a "vintage" Zend Framework release using includes?
An alternative possibility, if what you want is to introduce Dependency Injection in your ZF 1.11 project, is to use the Symfony DI component. I worked fine for me.
There are some web resources about the details, most notably this one: http://losohome.wordpress.com/2010/01/22/integrating-symfony-dependency-injection-service-container-with-zend-framework/
Hope that helps,
My advice at this stage is to develop your project with ZF 1.11. 2 will not be backwards compatible with ZF ZF 1.11, but there is talk of some tools / tutorials that will help to update, but I am very skeptical about it!

Getting started with Doctrine for Zend

I'm trying to get started with Doctrine for Zend. There doesn't seem to be a lot out there to help me with this. I find the website and documentation a bit useless.
I'm currently looking at this webpage.
There are a few options. I can checkout from subversion or github. Install via PEAR. or download a package.
What should I be doing with the lines of code in the black boxes?
What do I do with a package once I've extracted it?
As an aside
Am I a little out of my depth? Is there anything I should be learning before I start tackling Doctrine?
You really should have a look at the Zend Framework webinars, and more specifically the one called Zend Framework v1 + Doctrine v2. It's got detailed instructions and links to GitHub where you can download the source presented in the webinar.
The presentation slides can be found at http://static.zend.com/topics/Zend-Framework-1-+-Doctrine-2.pdf.
Presentation summary :
Zend Framework (version 1) is an
enterprise grade, full stack MVC
framework and component library.
Doctrine (version 2) is an enterprise
grade, ORM (object-relational mapping)
framework for PHP 5.3. In this
webinar, the ZF and Doctrine teams
join forces to demonstrate how best to
integrate these two frameworks and
produce a ZF powered MVC application
where in which the "M" is powered by
Doctrine2. Familiarity of PHP 5.3
features is suggested. Presenter –
Ralph Schindler, Jonathan Wage and
Guilherme Blanco (87min) Dec 15 2010
You will have to register with Zend though (but that's free, so shouldn't pose any problems I guess).
Actually, there are some resources you could use to integrate Zend Framework and Doctrine. In example, you could follow this screencasts:
ZendCasts - Doctrine
I've followed these screencasts, with a few corrections, and I was able to use Doctrine 1.x with Zend Framework applications. You can also view the generated screencasts' code; this option is available in the most of these screen casts.
You will want to use Doctrine 2, not version 1.2. The two are not compatible. Here is a presentation that explains why:
http://www.slideshare.net/ralphschindler/zend-framework-1-doctrine-2-6177485
Here are example sources for Zend Framework + Doctrine 2 integration:
https://github.com/fierycode/ZendFramework1-Doctrine2
https://github.com/marsbomber/zf1-doctrine2/tree/modular_setup (with modules)
I have already pointed someone in the right direction to integrate Doctrine 1.2 into ZF, my post can be found here.
I hope this helps you out.

Propel or Doctrine for ZF integration

I have never used any ORM, but the Zend_Db_Table (if you can call it one). I'd like give it a try with some famous ROM and I've only heard of these 2 (Propel and Doctrine).
I tried sometimes in the past but I found it too hard to integrate or maybe I didn't understand how it works.
Now that I'm trying again, I'd like to know which one has easier integration with Zend Framework and which one is easier to work and why
Doctrine and Propel are definitely the two best know PHP ORM's among some others.
Doctrine has definitely seen some more love from ZF and there is rumors that Doctrine 2 will play a major role in ZF2, though afaik nothing as been confirmed as of this writing.
Here is some links for you to follow:
Integrating Propel with the Zend Framework (2006)
Brandon Savage: The Adventures Of Merging Propel With Zend Framework
and
Ruben Vermeersch: Integrating Zend Framework and Doctrine 1.x
Matthew Weier O'Phinney: Autoloading Doctrine and Doctrine entities from Zend Framework
Doctrine 2 and Zend Framework first date
Also see these two questions that have additional information and links:
Zend Framework 1.9 and Doctrine Integration
Integrate Doctrine with Zend Framework 1.8 app
Should not be hard to find many more for Doctrine.
EDIT very nice one from Phil's comment:
Zend Framework / Doctrine integration suite

PHP MVC framework for ASP.NET MVC/NHibernate developer

For class, I would like a to use PHP MVC framework very similar to ASP.NET MVC with NHibernate. I am very comfortable with ASP.NET MVC. I need to use PHP and MySQL. I would not like to be concerned with the SQL to save me time. I would like to just design my PHP model classes and controllers without all of that data-access logic behind it that I would have to write.
Any suggestions? Thanks.
Also, I'm very limited on what I can install on the server. For instance, I can't upgrade PHP or run other installers. I want something I can drop in.
I prefer Zend Framework MVC components combined with Doctrine if really want great power. but for something simple try CaKePHP as it has its own simple ORM implementation, and the framework is built to be the php version of Ruby on Rails.
My personnal preference for "MVC Framework" would probably be Zend Framework -- though it's not the only possible choice (I'm thinking about symfony too, for instance).
About the "not writing SQL" part, I would use Doctrine, which is a great ORM Framework.
It's actually the default ORM Framework of symfony, and can be used with Zend Framework quite easily.
I suggest Symfony. It uses Doctrine (which is inspired partly by Hibernate) too, but it is integrated deeper with Symfony than Zend Framework. Symfony provides a number of helper classes which really help automate things with Doctrine (my favorite is sfDoctrinePager). Zend Framework is a good choice, but I recommend looking at Symfony first. I would avoid the other PHP MVC frameworks as they tend to be less flexible, and if you're coming from another language you may have your own preferences on how to attack a certain problem - Symfony and ZF will both give you leeway in this sense.

should i learn zf2 to use zend expressive

For those that have begun playing around with zend expressive, does it require knowledge of zend framework 2? meaning do I have to learn/know zf2 in order to use Expressive? or did they make enough changes where learning zf2 would be pointless/confusing?
along those same lines, other than the zend-expressive.readthedocs.org page, can anyone recommend some good tutorials/walk-throughs to get started ?
I would say that the knowledge of Zend Framework 2 is not required to work with Zend Expressive. Certainly, the two share some components (Zend.Mvc for the routing and Zend.ServiceManager for DI, if you choose them in Expressive) and the logic of some things is similar, so a knowledge of ZF2 would not go wasted. But if you don't know it, you don't need to learn it before starting to use Expressive.
Regarding some useful resources on Expressive, here are some:
http://www.sitepoint.com/build-nasa-photo-gallery-zend-expressive/
http://www.masterzendframework.com/zend-expressive-introduction/
https://github.com/RalfEggert/zend-expressive-tutorial
https://www.briefs.fm/zend-framework-bites
You don't need any zend framework experience to start with zend expressive. But it gives you a head start when using zend components in your project.
Some more links to get you started:
Official docs: https://zendframework.github.io/zend-expressive/
Project examples: https://zendframework.github.io/zend-expressive/reference/expressive-projects/
If you already know Zend Framework, namely things like,
PhpRenderer
ServiceManager
ViewModel
it will help you, because you can choose those ZF components to go into your Expressive configuration and get a good head start, instead of taking baby steps learning what those are.
But, if you do not already know those, there is no reason to learn Zend Framework and I could argue that learning Zend Framework, in order to use Expressive, will be detrimental.
That is, because, Expressive, builds on new ideas of a microframework, and using pipelines of Middlewares, rather than a pre-determined pre-set pipeline of Zend Framework's zend-mvc module, and Middlewares and zend-mvc are quite different. If you are new to Expressive, I'd look into each concept separately and pick the components you wish to use. The concepts are
Routing
Dependency Injection Container
Templating
You can also pick your own Error handling module. Also Expressive gives you standard compliancy, such as PSR-7 and PSR-15 when it becomes available.
If you already know Zend Framework, namely things like,
PhpRenderer
ServiceManager
ViewModel
it will help you, because you can choose those ZF components to go into your Expressive configuration and get a good head start, instead of taking baby steps learning what those are.
But, if you do not already know those, there is no reason to learn Zend Framework and I could argue that learning Zend Framework, in order to use Expressive, could be detrimental.
That is, because, Expressive, builds on new ideas of a microframework, rather than a pre-determined pipeline of Zend Framework, and those are quite different. If you are new to Expressive, I'd look into each concept separately and pick the components you wish to use. The concepts are
Routing
Dependency Injection Container
Templating
You can also pick your own Error handling module. Also Expressive gives you standard compliancy, such as PSR-7 and PSR-15 when it becomes available.
It can be good to know Zend Framework (or similar framework) because working with those frameworks gives you an understanding of how those components are built, and how they connect. However, Expressive Skeleton gives you a pretty good idea and a good headstart on very good groundwork concepts and modern web development (routing, templates, error handling, DI container). Newer concepts in Expressive are Middlewares and piping them together. Those were not present in Zend Framework at first, but now they made it in there as well.

Categories