Here at BePro Software, we are constantly reviewing the latest technologies from AMP to AWS. In this article, we want to review a project we recently created using the MVC (Model, View, Controller) PHP framework known as Zend. We also talk a little about a new up and coming javascript library known as angularJS.

In this article we use them together. Instead of AngularJS VS Zend, here we show how they work together. AngularJS will handle all of the front end interactions and validations as we have come to expect from a Javascript library. Zend will process the submission on the backed including all database interactions.

THE PROJECT

This is a simple booking project, created to get a taste of both technologies. Feel free to download and review the code on our github repository

There is extensive documentation in the code and readme file to help you navigate the technical details. In this article, we will stay at a purely architect/analyst level, allowing us to understand the pros and cons of these technologies and the hurdles involved with utilizing them. If you would like to delve into the technical elements of the technologies, you can review the code in the github example. It should compile on your Linux Apache server

ANGULARJS

This javascript library, much like the popular jQuery library, is used to manipulate the DOM (document object model). In short, its a programming scripting language used on the frontend of websites to make them dynamic. If you are used to jQuery, then the learning curve for AngularJS should be short. So for comparison sake, since jQuery is so popular, we will use it to showcase the benefits and issues with AngularJS.

At first we found AngularJS cumbersome. It intrudes into the html in a way that jQuery never did. For example, once AngularJS has control of a form input field, your hard coded “value” attribute no longer works. This is now controlled by AngularJS, so you must initialize the value with it.

On the other hand, this intrusion makes some things easy. For example, in the past, when you want to create a selectbox (aka dropdown) option with jQuery, it can be tedious to set one of the options as “selected”. When hard coded, these options can require lots of coding to outline the options and specify which one is selected. With AngularJS, you can easily specify the options as an array and specify the selected value with a single line. This is where you really see the power of AngularJS over jQuery.

ZEND FRAMEWORK 3

Our team has had extensive experience with MVC applications, from CMS solutions like MODx to popular frameworks like Kohana and CakePHP. This 3rd incarnation of the Zend Framework, is pitched as a dynamic codebase which can be configured to be lighter than most but flexible enough to take on the competition. In our case, we utilize a particular flavor known as “expressive”

At first, Zend seemed like a lot of work for nothing to us. Unlike its competition, there isn’t a scaffolding option for rapid development. Also simple things like the routing are not intuitive, nor do they go far enough in simplifying the linkage between the url and the actions in your controller.

We also have a pet peeve about frameworks that profess to be MVC, but the method by which you go about implementing it can be different from installation to installation. With Zend, the location of your controllers and Models are dynamic and totally up to the developer. This all has to be specified in config files. So reviewing an example online might not be very helpful although the example covers the exact same issue. That’s incredibly frustrating, are you really going to change your whole project around so it looks and works like the example?

On a positive side, all of the features you need are at your finger tips, PDO, templates, project building tools (composer), and strong OOP are included from launch. Various functionality is available via plugins. Once you wrap your brain around how to include them and use them, their use becomes intuitive and dynamic.

HYBRID UTILIZATION

Using the two technologies together was simple enough. We implemented ajax (json) calls on the front end. These calls are posted (submitted) to a custom ZF3 controller where it is validated and passed on to the model where simple PDO commands handle the database interactions.

Error handling was managed by the Whoops error templating system. This system shows errors in fairly interesting layout which should theoretically make error tracing relatively simple. We found it useful in some cases and a waste of time in other. Then again, a lot of that is probably a result of the underlying Zend Framework. Some errors were easy to identify and fix, which others were a complete mystery.

Documentation on both technologies is abundant. ZF3 was a little harder to follow just because of how dynamic it is. You can be looking at a github repository with the information you need, but its laid out completely different to your project. There is also different ways of doing things period, so an example might do what you need but not provide the syntax you need with the path you took on your application.

CONCLUSION

AngularJS and Zend Framework 3 Expressive are great tools for the right project. If you need something to be developed quickly, you may consider Kohana or CakePHP to be better tools. If on the other hand, you want to build a robust, complex, and stable website ZF3 might just be a great choice.

For the jQuery fans out there, AngularJS is rising in popularity for good reason. It simply does some things better than jQuery. With that said, jQuery has been around for a long time. There are tons of plugins/addons for it that are robust and work very well. There is also tons of documentation and examples available. We wont be switching any of our products to AngularJS right away, but we are definitely tempted to include it in upcoming projects

Every technology has its perks and downfalls. These 2 titans are no different. If you are used to MVC and javascript libraries, it will be relatively easy to get up to speed on these. We recommend utilizing our github repo to get a head start on understanding the technologies.


Date: Zend Framework 3 Expressive with AngularJS was last modified: August 7th, 2019 by elbon Management at BeProSoftware.com

Leave a Reply