 | News Feed |
 | Jobs Feed |
Sections
|
| feed this: |  |
Derick Rethans' Blog: Multiple PHP versions set-up
by Chris Cornutt November 07, 2011 @ 09:14:00
Derick Rethans has a new post today looking at a method for setting up multiple PHP versions on the same machine and switch between them with a little help from some simple bash scripts.
For many of my projects (both hobby and commercial) I need to support many different PHP configurations. Not only just different PHP versions, but also debug builds, ZTS builds and 32-bit builds. In order to be able to test and build extensions against all those different PHP configurations I have adopted a simple method that I'm sharing with you here.
Using this script he can tell his system to pull the latest version of any release from SVN and try to compile it. The trick is putting each of them into a different directory under /usr/local. He uses another small shell function (with a function called "pe()") that sets up the pathing to the right release, complete with its own locations for PEAR/PECL and a php.ini.
voice your opinion now!
multiple version setup bash script switch tutorial
Martin Psinas' Blog: Switching to PDO
by Chris Cornutt August 04, 2011 @ 10:17:59
In a new post to his blog Martin Psinas talks about some of his pains experienced with upgrading his code to use PDO instead of the mysql extension for database interaction.
I read not too long ago that the mysql library in PHP is being deprecated as of v6.0 in favor of mysqli or PDO, so of course I had to update all of my database code keep on top of things. I spent about 5 or 6 hours over the course of 2 days familiarizing myself with the new syntax and updating my code offline. Without any testing, I decided I could go ahead and push the code "live" because I'm just that over-confident sometimes, although I did make a backup in case anything went wrong (or so I thought).
Two problems jumped out immediately - a SQL error caused by this bug and the other being a problem with preparing his statement inside of a session handling method.
voice your opinion now!
pdo mysql switch problem prepare session limit bug
Lorna Mitchell's Blog: One-Step Symlink Switch
by Chris Cornutt August 20, 2010 @ 10:03:39
Lorna Mitchell has a handy tip you can use in deploying your (linux-based) PHP applications - a one-step symlink switch that can make toggling between deployed versions of your code simple.
When I deploy an application, which is almost invariably a PHP application, I like to put a whole new version of the code alongside the existing one that is in use, and when everything is in place, simply switch between the two. As an added bonus, if the sky falls in when the new version goes live, the previous version is uploaded and ready to be put back into service.
The single command avoids having to remove a current symlink and recreate it, possibly causing issues if something happens in between. Instead she uses the "mv" (move) command to push the current symlink over to a new location. Reducing the process to one step also minimizes the risks of deployment.
voice your opinion now!
symlink switch deployment application
Michelangelo van Dam's Blog: Zend Framework context switching for HTML content
by Chris Cornutt April 16, 2010 @ 08:43:35
Michelangelo van Dam has a new post to his blog today looking a a method for doing some context switching in his Zend Framework application to use jQuery in his app's static HTML output.
I had already build my apps using static HTML output generated by Zend Framework, so how could I add this richness to my apps without refactoring most of my code ? Simple, by using Zend_Controller_Action_Helper_ContextSwitch, ZendX_JQuery and some minor adjustments to my view scripts.
He includes some code (that's confirmed to work with ZF 1.10.3) using the contextSwitch method on a helper object that adds in the "json" type for the contexts that can be used for the responses. Then a new template is added for the type (like index.json.phtml for the json output). Make a change or two to your bootstrap file to add in the right jQuery helpers and your view is as simple as calling "$this->jQuery".
voice your opinion now!
zendframework context switch html tutorial
Zend Developer Zone: Adding Multi-Language Support to Web Applications with PHP and PEAR
by Chris Cornutt April 24, 2009 @ 14:48:15
On the Zend Developer Zone today a new tutorial has been posted about multi-language translation for your site with PHP and the Translation2 PEAR package.
If you're using PHP, adding multi-language support to a Web application is quite easy, especially since the PHP Extension and Application Repository (PEAR) includes some ready-made code to help you get started. And that's where this article comes in. Over the next few pages, I'll introduce you to PEAR's Translation2 package, and show you how you can use it to add multi-language support to your application.
You'll need to have everything up and running (including an install of the PEAR package) before getting started. The tutorial shows how to set up database tables and sample data to reference with a basic "Hello World" script as well as a few more complex examples involving user input and creating a cross-language menu for a sample site.
voice your opinion now!
pear tutorial translation2 package language switch
Debuggable Blog: Code Insults Round 1 - Why switch blocks are dumb
by Chris Cornutt October 29, 2008 @ 08:48:28
In the first of his "I will insult your code" series, Nate Abele looks at this submitted code and points out that maybe blocks of switch/case statements aren't such a good idea after all.
The entire submission is actually two files, which together comprise a console script for interacting with a web service (the names of the entrants have been withheld to protect the identities of the guilty). Rather than examine the full entry, we're going to take a look at one part which I find comes up fairly often: switch block overkill.
The example he's talking about has a switch statement with eight different cases under it, most of them just setting two properties on the current class. Its used ot map command line parameters to their correct properties. Nate suggests a bit different method - still using switch/case but pulling the properties to be assigned from an array of options rather than hard-coding them into the evaluation.
voice your opinion now!
switch case block insult refine overkill property
Debuggable Blog: How to bend Cake's Modelfind() method to your needs
by Chris Cornutt June 23, 2008 @ 12:08:32
New on the Debuggable blog, Tim Koschutzki has posted a method to get the fund() method in the CakePHP framework's models to bend to your will.
CakePHP allows you to use your own "find-types" for the Model::find() methodology. Those of your who are familiar with the find() method know that there are currently four types in the core: 'list', 'all', 'first' and 'count'. However, sometimes it is nice to specify your own type.
He shows an example of the end result - a find() call with a custom type that automagically gets translated correctly. His script overrides and enhances the usual find call in an extended object (extended from AppModel) that uses a switch/case statement to define the custom types and their find() search calls.
voice your opinion now!
cakephp framework find custom type model switch case
SitePoint WebTech Blog: Give Your Visitors a Rough Time
by Chris Cornutt March 06, 2008 @ 08:44:00
In a new post to the Web Tech blog over on SitePoint, Toby Somerville has posted something he calls "RoughTime" - his method for displaying a more "human friendly" output of a timestamp.
When asked the time, we generally don't need to be military accurate with our response [...] we generally communicate the approximate time. i.e. 'its nearly ten' or 'its just gone half past three'. Yet on the web, time is generally shown as '12:24:13 AM', or similar '" not very visitor friendly.
His RoughTime uses two switch statements to map the hour and minute values to different strings. For example, minutes between 15 and 20 become "quarter past" and the hours are changed over from numeric versions to their word counterparts.
voice your opinion now!
roughtime switch approximate time hour minute translate
|
Community Events
Don't see your event here? Let us know!
|