All entries of my technical and business blog.

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

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... (more…)

Zend Framework Static Router URLs Not Found in Zend Navigation

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... (more…)

How to Quickly Mask a Credit Card Number

So, often I have to show a masked credit card on the screen. However, I really want to go the extra mile and show the user a secure, fully masked credit card number that still reflects their original card. For example, if their credit card number is only 15 numbers long, I shouldn’t show a 16 character long string. So, I’ve developed this code snippet: $cc='1234123412341234'; $masked = str_pad(substr($cc, -4), strlen($cc), '*', STR_PAD_LEFT); (more…)

Mod Rewrite to index.php file, the easy way

How many of you have written this before (or something very much like it): RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [NC,L] RewriteRule ^.*$ index.php [NC,L] (more…)

Add PHPUnit Listeners to Watch for Long Running Tests

One of the under-utilized features of PHPUnit probably is the listeners interface. You can see the configuration options here: php.net/appendixes.configuration.html. So, I decided that I want to use this to know if a Unit Test takes longer than 2 seconds to run. That’s super over-kill in my opinion, but that’s my hard limit. If it takes longer than 2 seconds to run, something is wrong! So, I added the following to my configuration: (more…)

Setting PHP Command Line Colors

I’m not entirely certain why this escaped me for so long, but it’s remarkably easy to set terminal colors with PHP. Simply echo the escape/color character \033, followed by the bash color definition and your output. For reference, here is a listing of bash colors. So, for example, if we want to make something blue text, do the following: (more…)

php

When you Create Your Account, Please log in.

I’ve always found it annoying when programmers create systems where you create your account and then you’re not logged in. Maybe I’m lazy? I decided to do a poll on a popular social networking site. The poll went like this: (more…)

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

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. (more…)

⬅ Newer | Older ➡
Page 23 of 50
or use RSS