Categories
zend framework 2

Zend Framework 2 Advanced database operations ?

In this post i would like to list basic to advanced database queries using ZF2. I am gonna use TableGateway methods here. Simple Select Query SQL statement is Select Query with Where condition SQL statement is Select Query with Where condition SQL statement is SELECT MAX(field) SQL statement is SELECT MIN(field) SQL statement is SELECT […]

Categories
zend framework 2

How to return JSON response in Zend framework 2

In this post, I just want to show you how to return the response in JSON format in the correct way in ZF2.Returning JSON response is very useful and we almost use for all AJAX integrations. Let’s see the below example for better understanding. Actually above solution is pretty much the clearest solution and correct […]

Categories
zend framework 2

How to configure multiple databases in zf2

Configuring multiple databases adapters in zf2 is pretty easy. In this post i will show you how to configure and connect to different databases in zf2 application. Adapter Abstract Service factory(Zend\Db\Adapter\AdapterAbstractServiceFactory) allow us to create multiple DB adapter instances in zf2. In this example i am adding two extra database adapters apart from the default […]

Categories
zend framework 2

How to create your own controller plugin in ZF2?

Our step-by-step guide explains how you can create your own controller plugin in zf2.Fortunately creating controller plugin is very easy task. Create a directory called plugin in your module controller directory, then create a file for example ,Myfunctions.php. then place the blow code. Myfunction.php file is a php class that will extend the zf2’s AbstractPlugin, […]

Categories
zend framework 2

Zend Framework 2 installation on Xampp ?

In this tutorial i will cover the ZF2 installation on xampp for windows operating system. 1.First you need to download and install xampp server from apachefriends 2.Download and install GIT from Download GIT 3.Download and install Composer from Composer Download 4.Now go to c:xampphtdocs the create a folder called zf2(you can change) right click on […]

Categories
zend framework 2

How to Create Custom View Helper in ZF2

In this post I will show you how to create a custom view helper in ZF2, writing custom view helper in zf2 is very easy thank to zf2 authors. Here in this example i am goanna create StaticFileVersioning Module, you can place this module in two different places , one is vendors directory and other […]

Categories
zend framework 2

How to Send HTML Mail Using Zend Framework 2 (ZF2)

ZendMail provides generalized functionality to compose and send both text and MIME-compliant multipart email messages. Mail can be sent with ZendMail via the MailTransportSendmail, MailTransportSmtp or the MailTransportFile transport. Of course, you can also implement your own transport by implementing the MailTransportTransportInterface

Categories
zend framework 2

How to Get Last inserted ID in Zend Framework 2?

We often need last inserted ID for different reasons(for example when you need to store foreign key), Immediately after a record has been inserted into the database, you can get the id that was auto incremented(primary Key). After Inserting data into table , we can get Inserted ID the following ways Using Abstract Table Gateway […]

Categories
zend framework 2

How to redirect to 404 page in zend Framework 2

The Zend framework automatically does this if the user selected route doesn’t exists. Although in some situations like getting data from database where the route is valid , but response is 404 (row not exits or may be row has been removed), in that case ,where may be we should have to show 404 page. […]

Categories
zend framework 2

How to Create,Get,Check Sessions in Zend Framework 2?

In GF2 in order to use Sessions we should use this use ZendSessionContainer; class. This class Container extends of ArrayObject and instantiates with ARRAY_AS_PROPS flag that means you can easily iterate through properties and read/write them. After Placing above line of code in place , you need to instantiate the ZendSessionContainer class and pass a […]

Categories
zend framework 2

Zend Framework 2 – Cache Example

In this post, i will show you how to cache your data in ZF2 using “filesystem” adapter.We can directly instance the “ZendCacheStorageAdapter* ” classes or you can implement factory . It’s always better to create caching adapters by using factory for avoiding to do it manually for each time.With the help of service locator we […]

Categories
zend framework 2

ZF2 Cache:How to Enable The merged configuration cache ?

Zend Framework 2’s Module Manager has the ability to cache the merged configuration information for your application.merged configuration Means that all module configs and class maps over modules are merged in ZF2, in general on each request , this merging process will reduce the application performance. In order to improve ZF2 app performance we need […]

Categories
zend framework 2

Zend Framwork 2 : How to use Service Manager in controller plugin.

Categories
zend framework 2

How to compress html output in zend framework 2 ?

Today’s post is About HTML Output Compression, we can reduce 10-20% load on the server by compressing the HTML output(bandwidth save, faster page loading) we can easily compress the html Output in zend framework 2, with the help of zf2 events. On your main Modle.php create an event that will trigger on finish, module/application/modle.php