zend framework

Changing Layout in ZF2 Controller

November 15, 2015 by

Changing the layout or template within a Zend Framework 2 is easy. Thanks to the layout controller plugin, one can change the layout for a given controller action in just one line. public function indexAction() { $this->layout(‘layout/default’); return new ViewModel(); } As you can see above, the only thing you have to do in order… read more

Get Base Url within ZF2 Controller

November 15, 2015 by

Getting the base url of a request in Zend Framework 2 is quite simple. Because you are probably extending the AbstractActionController class, you get some functionality out of the box, including easily accessing the current request. From the request, one can get the URI, which exposes various methods for different parts of the URI. In… read more

Getting URL Parameters in ZF2 Controllers

November 13, 2015 by

Accessing URL parameters from controllers in Zend Framework 2 is extremely easy thanks to the params controller plugin. This plugin exposes various methods that one can use to retrieve parameters from various sources of a request, including from the URL. I will give examples of the various sources below. Getting URL Parameters To get URL… read more

ZF2: Accessing View Helpers in Controllers

July 4, 2014 by

Generally speaking, view helpers should not be used within controllers, as the name suggests. Certain situations may, however, require one to do so. This article shows you just how to do that by fetching the view helper manager from the service manager. It is actually very simple. public function someAction() { $userData = ‘User data… read more

Create Full URLs in ZF2 Views

March 10, 2013 by

Creating full URLs within view scripts can come in handy in many situations, such as when sending out e-mails where one wants to link back to one’s website. Luckily, Zend Framework 2 provides two useful view helpers to accomplish this task.

Use SSL or TLS with SMTP in ZF2

February 28, 2013 by

If you wish to use a secure connection when sending e-mails via an SMTP server in Zend Framework 2, then this article shows you how to do this. The official documentation comes to no avail, but luckily the solution is extremely simple.