Tag Archives: zend framework

Zend Framework 2: Single routing to manage all routes

In ZF2, many people writes as many routing rules as many routes they need. If there are many routes, then its will create a big list of routing rules whill will result in performation and memory consumption also. If there is no requirement of user friendly or custom routes, then we can manage all routes… Read More »

Zend Framework 2 : Mail

Step 1 : Create a new module ZF2Mail to manage mails in Zend Framework 2 Step 2 : In /path/to/yourapp/vendor/ZF2Mail/config/module.config.php

Step 3 : In /path/to/yourapp/vendor/ZF2Mail/src/ZF2Mail/Mail.php

Step 4 : In /path/to/yourapp/vendor/ZF2Mail/Module.php

Step 5 : In /path/to/yourapp/vendor/ZF2Mail/view/emails/templates/

Click here to download the module : Download

Zend Framework 2 : Manage Sessions

Refer : http://framework.zend.com/manual/2.1/en/modules/zend.session.storage.html Step 1 : Full Code

Step 2 : Create Session

Step 3 : Check Session key existence

Step 4 : Distroy session

Zend Framework 2 : Different layouts for different modules

Step 1 : Create Module MyModule with similar structure to default module Application Step 2 : Add module MyModule in /path/to/yourapp/config/application.config.php

Step 3: Add invocable in /path/to/yourapp/modules/MyModule/config/module.config.php

Step 4 : Create mymodule.phtml as layout for module MyModule with diffrent design Step 5 : Add module layout location information Add module layout location information… Read More »

Zend Framework 2 : Call another controller action from other controller

Step 1 : Create two controllers IndexController.php and TestController.php

Step 3 : Create template show.phtml

Zend Framework 2 : Check for valid controller class, action method and template

Step 1 : Create AppController.php and extend all controllers with this controller

Step 2 : Create view files Create index.phtml in /path/to/your/app/module/Application/src/view/application/index/ Create test.phtml in /path/to/your/app/module/Application/src/view/application/index/ Step 3: Create IndexController.php

Zend Framework 2 : Add javascript/css files dynamically

Step 1: Create AppController.php to have common functionality to be shared in all controllers and extend all controllers with this class

Step 2 : Add _getHelper() method in AppController.php

Step 3 : Create any controller in any module.

Step 4 : Append/Prepend javascript files dynamically in ZF2 from controller in header section… Read More »

Start with Zend Framework 2

Step 1 : Go to https://github.com/zendframework/ZendSkeletonApplication and download sample application in Zip format. Unzip this zip file into the directory where you keep all your applications

Step 2 : Download the latest ZF2 library from http://framework.zend.com/downloads/latest After download, unzip the zip file and place the ZF2 library folder in “vendors” folder.

Alternative solution… Read More »