Entries with the tag “zend-framework”

These blog entries are about the Zend Framework so they’re tagged with “zend-framework” - however, this project is now called Laminas.

Zend Translate Plurals

Sep 24, 2013 zend-framework

I know it should be pretty common sense to RTFM - but sometimes you miss things.

Zend Framework 1 and jQuery Validate Plugin: how to create password/confirm easily in Zend_Form

Jul 16, 2013 jquery zend-framework

Perhaps this trend is going away, but it used to be a “good thing” to make people validate their passwords. I did all kinds of silly things in Zend Framework Form and jQuery Validate plugin at first - but then I finally settled on a good solution. It’s quite simple actually…

Zend Framework 1 Form Captcha Idea

Jul 2, 2013 zend-framework

One of the worst things with CAPTCHAs are actually having to solve them. One of the things my team and I use for our projects is the hidden field CAPTCHA. This is a technique that adds a field to a form, but uses CSS to hide it. If that form value is filled in, we can guess that the submitter was a bot reading the HTML - and not an actual user.

Using custom view scripts for Zend_Form in ZF1

Dec 25, 2012 zend-framework

To start out, I realize that a lot has changed in Zend Framework 2 regarding Zend_Form. I think there have been a number of interesting changes, but perhaps those changes weren’t explained that clearly either. But I digress. This piece is about Zend Framework 1.12.x Zend Form - and using view scripts for elements/the form.

Duplicate request issued in ZF when using inline script/document.writeln in view

Nov 20, 2012 php zend-framework

This is a weird one… I had a form in the body of my page. Every time I would submit it, the csrf token would not match.

Zend Framework ACL: Inherits Including

Sep 18, 2012 zend-framework

So one of the things that really bothered me about the Zend ACL implementation in 1.x was the inherits() method. It simply would test to see if the current role inherited the roles you were testing against. Well, what if the role WAS the tested role? Then it would fail. So, to fix that, in my own Application_Model_Acl implementation, I wrote inheritsIncluding().

Zend Framework: Add HTML to form element label

Aug 21, 2012 zend-framework

By default, the labels of form elements in Zend Form are escaped. Sometimes, like in check mark boxes for Terms of Use, it makes sense to add some HTML to this. You can turn off escaping - but just be careful!

Testing Error 500 Pages in Zend Framework

For the most part, ZF can capture any of your hard errors. It will generate an error 500. You’ve seen them, don’t lie… I’ve seen them way too many times. However, in my production application, I capture these with a specific controller. And because I love Unit Testing, I want to make sure that I test my implementation of my omg-this-is-broken setup.

Filtering User Input/Output in Zend Framework

Jun 26, 2012 security zend-framework

There are two areas where user input should be filtered: on display and on storage. Luckily, Zend Framework provides tools for this…

Store Zend Framework Options in the Registry

Jun 19, 2012 zend-framework

So, since I want to save some keystrokes, I rarely will go back to the Front Controller and Bootstrap to get resources. I also like to store them in the registry in a fashion that I see fit.

Translate Your Error Messages in Your Zend Framework Controllers

May 1, 2012 misc-web zend-framework

I’ve been making a push to have more of my projects multi-lingual. However, one thing I kept forgetting about was those super-rare error messages that have to come from the Controller. For the most part, all of your errors should be handled by your validators in your forms. However, from time to time, there needs to be an error handled in your controller.

Extend Zend_Mail to use Views

Mar 20, 2012 testing zend-framework

I love working in the Zend Framework view system. One thing that bothers me, however, is that I must create a complex set of models when trying to send email. I decided that I’d like to move all of this output for the mail class into my own view system as well.

Removing the extra elements on Zend_Form for Submit Button

Mar 13, 2012 zend-framework

Have you ever used Zend Form, created a submit button, and had a few extra tags that were just throwing you off? I know you have… You probably did it like me:

Zend Framework Use Filter with Paginator

Feb 21, 2012 zend-framework

By default, when using the Zend Paginator, the result set will come back as an array. If you are using a paginator associated with a database result set, and that db has a class defined for its row, it will come back as that class. However, if this is not the case, or you are not using information from a database, you may still want a different result than just a plain array.

Creating a custom Zend Framework Body Script helper

Jan 31, 2012 javascript zend-framework

It drives me nuts that the best practices with javascript that is not required for the initial rendering of your application is to be placed at the bottom of the document, yet frameworks (like Zend Framework) do not support that out of the box. (I recently found out that Joomla also shares this problem.)

Split Read/Write Connections in Zend Framework Database on the Application Level

Jan 24, 2012 mysql zend-framework

I’m no sys admin, so I can’t be sure, but I’ve seen lots of issues with using things like MySQL Proxy to fully separate the write and read queries in an application. Maybe it works, I don’t know… but I do know that if I can separate the connections in my code, that saves my Admin time… it doesn’t appear to give that much of a hit to performance either! Do keep in mind that this is only working at the table level in Zend Framework. If you use their database system, this should do the trick. If you do a lot of getting the adapter yourself, this won’t help you at all!

Zend Framework Static Router URLs Not Found in Zend Navigation

Jan 17, 2012 zend-framework

For a CMS I’ve been working on, there are a number of custom routes that are added statically in a loop. These point to specific ID’s of articles on on the default module’s page viewing controller/action. Sometimes these routes need to appear in the Zend_Navigation output. As you can probably guess, the logic used for this is similar to what you might experience when using the URL view helper. But, for some reason, I could never get the URL’s to be marked as active.

Zend Framework Authentication: Let the user know if it is their fault

Nov 29, 2011 zend-framework

One of the things that is irritating is logging into a website with credentials that you know are right, only to have it fail. Then, later, you find that the site was malfunctioning. By then, maybe you requested a new password, or had to at least waste time looking up your old password. With Zend_Auth, however, we can prevent user’s from having that issue.

Service Class Methodology

There has been a lot of discussion on forums and throughout the object oriented PHP programming community about service classes. This is just intensified by the Zend Framework model of development coupled with the changes in their design/architecture and vocal spokespeople. I thought I’d throw my hat in the ring for this.

Zend Framework Front Controllers vs Bootstrap: Round 2

Aug 2, 2011 zend-framework

This article is the follow-up to the original article

There was some discussion on Twitter regarding the original version of my article about putting most of your site’s setup in the front controller plugins in Zend Framework.

Testing Outgoing Email with Zend Framework

Jul 27, 2011 testing zend-framework

I was creating a new application with Zend Framework at work the other day and I started using my technique that I described here by adding the original email in my email address using the + sign. However, the current organization I’m at has a mailserver (Exchange?) that is either configured not to allow this or just doesn’t have this functionality built in. So, this won’t work. I solved this with a new implementation of the mail class.

Zend Filter Presentation

Jul 20, 2011 zend-framework

Thanks to Zend and their community organizers for the opportunity to do a webinar today.

Adding Subdomain Routes for all URLs in Zend Framework

Jul 12, 2011 zend-framework

All the examples I’ve seen for pulling information from subdomains are from the hostname router directly correlating one subdomain as a value to a single controller/action combo. This means they map username.website.com to something that basically looks internally like website.com/user/profile/var1/username. This is cool for simple one off tasks - however, what if you’re creating a multiple controller/action solution? For my example, I’m creating a CMS that will have a shared code base. However, on every page, I need to know exactly which site this is.

Zend Framework: to include or not to include

Jul 5, 2011 zend-framework

There are two ways of working with Zend Framework as a library in your project. These are including it in your project repository and using a shared copy on the server (like PEAR). Let us discuss both:

Forcing UTF-8 in Zend Framework with PDO

Jun 28, 2011 zend-framework

For some reason, I just had the most horrible time making sure that my connection from my Zend Framework code was speaking UTF8 at my database. Here are the key things to remember that I learned:

Useful Firebug Tricks with Zend Framework

Jun 17, 2011 zend-framework

Zend Framework has a few hooks with the Firebug browser plugin (with the FirePHP add-on). The two that I use are writing logs to the console and profiling of database connections.

Easy Flash Messenger Messages in Zend Framework

Jun 14, 2011 zend-framework

Through reading a few blog posts over the last year and my own trial and error, I’ve developed a way of using the flashMessenger Helper in ZF that works out really well for me. (Note: if anyone knows the original blog post that I got some of the view helper from, please comment!).

Zend Framework View Helper for QR Codes

Jun 7, 2011 zend-framework

Google Charts has a QR code generation service (here are the details). I decided that I wanted to create my own ZF View Helper to display these on my pages. This version that I am going to show just returns the properly formatted URL for the charts API. The view must create the img tag around it.

PHPUnit error with Zend_Session

May 31, 2011 phpunit zend-framework

Running a test, I ran into this error:

Zend Framework: Bootstrap vs Front Controller Plugin

May 24, 2011 zend-framework

Today I was reviewing some old code I wrote in Zend Framework. One of the things I was doing in the Bootstrap.php file was creating an function called _initViewSettings(). In here I set a bunch of values for the xhtml version, the css files to include, etc. Now I realize my mistake:

Theme/Template System in Zend Framework

May 20, 2011 zend-framework

Theme systems are very common in projects written on Drupal, Joomla, and Wordpress. I didn’t see much out of the box support for themes in Zend Framework at first. However, I was wrong. It’s pretty easy. The only real decision I had to make is if I want to make themes that extend a default theme - or themes that are simple and on their own / totally encapsulated. I will do the encapsulated version - but give some pointers on how you would do the other version, too!

Zend_db fill in multiple placeholders

Jan 11, 2011 zend-framework

I’ve been using Zend_db to create a query which does a simple search on three columns of a table. Fortunately, I found out that the where() statement handles single parameters intelligently when there are multiple placeholders. In the case that there are many placeholders but only one parameter, that parameter will be added to each of the placeholders the same.