Zend Framework is an open source, object oriented web application framework for PHP 5. Zend Framework is often called a 'component library', because it has many loosely coupled components that you can use more or less independently. But Zend Framework also provides an advanced Model-View-Controller (MVC) implementation that can be used to establish a basic structure for your Zend Framework applications.
Questions tagged [zend-framework-mvc]
148 questions
26
votes
5 answers
Zend Framework: Controller Plugins vs Action Helpers
Could someone give few tips and/or examples how Controller Plugins and Action Helpers are different? Are there situations where particular task could be accomplished with one but not another? For me they both look more or less the same and I'm often…

Laimoncijus
- 8,615
- 10
- 58
- 81
26
votes
4 answers
ZF2: Get url parameters in controller
I have experienced Zend Framework 1 and I've build some apps with that framework.
Now, I'm experimenting Zend Framework 2, but I'm stuck on the url parameters.
I've setup my routing like this:
// Setup for router and…

koenHuybrechts
- 868
- 4
- 15
- 28
20
votes
4 answers
How to render ZF2 view within JSON response?
So far, I have figured out how to return a typical JSON response in Zend Framework 2. First, I added the ViewJsonStrategy to the strategies section of the view_manager configuration. Then, instead of returning a ViewModel instance from the…

webjawns.com
- 2,300
- 2
- 14
- 34
16
votes
10 answers
ZF2 - Get controller name into layout/views
I know with ZF1 you would retrieve the module/controller name using custom View Helpers that would get the singleton frontController object and get the name there.
Using ZF2 as they've abolished alot of the singleton nature of the framework and…

creamcheese
- 2,524
- 3
- 29
- 55
11
votes
4 answers
How Can I Write Zend Framework URLs That Have Anchor Tags In The Body?
Using the standard MVC set up in Zend Framework, I want to be able to display pages that have anchors throughout. Right now I'm just adding a meaningless parameter with the '#anchor' that I want inside the .phtml file.
= $this->url(array(
…

mazniak
- 5,849
- 6
- 28
- 23
8
votes
2 answers
ServiceManager in ZF3
I know that this has been covered extensively in other threads, but I'm struggling to work out how to replicate the effect of $this->getServiceLocator() from ZF2 controllers in ZF3 ones.
I have tried creating a factory using the various other…

Max Griffin
- 439
- 2
- 5
- 11
8
votes
5 answers
ZF2: How to pass parameters to forward plugin which I can then get in the method I forward them to?
I have an Action method in Foo Controller which requires parameters:
public function fooAction($one, $two) {
$a = one;
$b = $two;
}
And I need to forward to that method from the other method of some Boo Controller. And one of those…

Green
- 28,742
- 61
- 158
- 247
6
votes
1 answer
How to serve static pages with Zend Framework
We currently employ Zend Framework and the MVC pattern on our website. We have large numbers of static pages, which are in random areas of the site. These pages are not simple HTML pages that can bypass ZF altogether... they would participate in…
John B
6
votes
7 answers
ZF2 - How to change the error/404 response page? Not just template but to set a new ViewModel
By default the page is set like this in the Application module.config array:
'template_map' => array(
'error/404' => __DIR__ . '/../view/error/404.phtml'
I want to change the page. I want new ViewModel for it full of variables. It means that…

Green
- 28,742
- 61
- 158
- 247
5
votes
3 answers
Zend_Auth best practices
My goal is to require login for certain pages. I am using Zend Framework MVC, and I'm trying to find examples regarding best practices.
Some notes on what I'm looking for:
I want non-logged in users to get a login box, and then return to logged in…

Jon Skarpeteig
- 4,118
- 7
- 34
- 53
5
votes
3 answers
ZF3 zend-mvc-skeleton internationalization not working
I'm trying to evaluate if it's already the right time to start moving to ZF3 (or keep developing my application with ZF2). Therefore, I installed the mvc-skeleton application and walked through the MVC tutorial (here) which worked perfectly until I…

l_r
- 1,060
- 12
- 23
5
votes
1 answer
ZF2 Models shared between Modules
I've just started setting up a new ZF2 application for a new project, based off the ZF2 skeleton, and am looking at their tutorial on Models.
tl;dr: how should I share a Model between multiple different modules, by putting it somewhere in a higher…

Benno
- 3,008
- 3
- 26
- 41
4
votes
9 answers
A Generic, catch-all action in Zend Framework... can it be done?
This situation arises from someone wanting to create their own "pages" in their web site without having to get into creating the corresponding actions.
So say they have a URL like mysite.com/index/books... they want to be able to create…

rg88
- 20,742
- 18
- 76
- 110
4
votes
2 answers
The valid pattern for ZF3 service DI for interconnected services
As far as I understand the valid pattern is:
a FooControllerFactory that instantiates the needed service(s) (FooService)
a FooController with constructor __construct(FooService $fooService)
the Controller acquires some basic data and gets a result…

Jan M.
- 127
- 2
- 14
4
votes
3 answers
How to render a page in zend framework 2?
I used below code to render a page in the controller action.
public function userinforeceiveAction()
{
$renderer = new PhpRenderer();
$map = new Resolver\TemplateMapResolver(array(
'userinfo' => __DIR__ . '/userinfo.phtml',
…

Mangala Edirisinghe
- 1,111
- 2
- 15
- 32