Welcome to Abdul Malik Ikhsan's Blog

Zend Framework 2 : MvcEvent – get __NAMESPACE__ / Module Name from Layout

Posted in Tutorial PHP, Zend Framework 2 by samsonasik on July 27, 2012

I just created a module named ZfCommons that can initialize common functionality over module. For this post, i want to introduce a set ‘layout variable’ functionality with example : __NAMESPACE__, so we can echo-ing the module name / __NAMESPACE__ from layout.

Read More

Zend Framework 2 : Handling Trailing Slash “issue”

Posted in Teknologi, Tutorial PHP, Zend Framework 2 by samsonasik on July 24, 2012

In fact, in web application, it’s better not to have two urls respond to the same thing. But we are a lazy programmer, right, RIGHT ? We don’t have a much time to remember the route where is end with “/” or not.
For example we have 2 url like this :
http://zf-tutorial/album/add – 200 – works fine
http://zf-tutorial/album/add/ – 404 – The requested URL could not be matched by routing.

To handle that, just add the empty “/” in the end of route segment :

    'route'    => '/[:controller[/[:action[/]]]]',

Or for “:slug” segment :

    'route'    =>  '/[:controller[/[:action[/[:slug[/]]]]]]',

I do not know if this is a best solution or not, but this is probably one of the easiest.

References :
1. http://zend-framework-community.634137.n4.nabble.com/Trailing-slash-td4655266.html

Tagged with:

Zend Framework 2 : Zend\Paginator : Paginate Your Data

Posted in Tutorial PHP, Zend Framework 2 by samsonasik on July 23, 2012

Zend Framework has a component named Zend\Paginator. It can paginate items into pages, paginate arbitrary data, not just relational databases, and fetch only the results that need to be displayed.

Read More

Zend Framework 2 : Create Your Custom View Helper

Posted in Tutorial PHP, Zend Framework 2 by samsonasik on July 20, 2012

In MVC Architecture, sometimes, we have to do a “logic” to manage a view. The Logic is called by View named View Helper. Zend Framework 2 has a ton of flexibility, so, we can create a custom View Helper if we want to -that can be called by View Layer over modules.
Read More

Zend Framework 2 : Zend\I18n\Translator\Translator – Translate your Web Application

Posted in Tutorial PHP, Zend Framework 2 by samsonasik on July 18, 2012

Zend Framework 2 comes with i18n Component which one of the features is translator. It can translate your content of the page that you register in file(s) as dictionary and called with this component. The type of format that can be handled by this components are :

Read more

Tagged with:

Zend Framework 2 : Purists vs Pragmatic Developer

Posted in Tutorial PHP, Zend Framework 2 by samsonasik on July 17, 2012

Kita semua tahu, bahwa segala macam teori yang ada, sebaiknya mendukung implementasi. Namun, pada akhirnya, teori kadang tak selalu bisa diimplementasikan dengan se-“ketat” yang seharusnya. Para developer aplikasi biasa terbagi menjadi 2, yaitu yang purists, dan yang satu pragmatis.
Baca Selengkapnya

Zend Framework 2 : ServiceLocator ControllerLoader – Get Module Configuration from Controller

Posted in Teknologi, Tutorial PHP, Zend Framework 2 by samsonasik on July 12, 2012

Zend Framework 2, dengan segala fiturnya, telah mengubah pola pikir dalam membuat aplikasi secara modular. Dalam setiap module yang kita buat, kita mempunyai file konfigurasi yang bernama module.config.php yang nantinya akan di-merge dengan file-file konfigurasi di module lain.

Baca Selengkapnya