Mar 16

PHP developer vs scripter

Jim Plush wrote an interesting article on what differentiates a PHP developer from a scripter in his opinion. He specifies in the intro that the criteria is for an ideal senior level developer. I agree with most of his criteria aside for the CSS requirement. I think it’s good for a developer to know CSS but if they are at the senior level then there’s a good chance they would never have to deal with the CSS in a project.

As for the other criteria he mentioned… I really need to touch up on unit testing :\

http://www.litfuel.net/plush/?postid=166

Mar 12

PHP 5 Zend Certification blog

I came across a nice little blog that can help you pass the PHP 5 certification exam. It will be covering the following sections:

1.- Syntax
2.- Anatomy of a PHP Script
3.- Data Types
4.- Variables
5.- Consts
6.- Operators
7.- Control Structures
8.- Errors and Error Management

Not bad for starters. The official study guide may not be enough so it’s always good to look around for other resources.

View BlogÂ

Feb 21

Image resize helper for Cake

A nice little helper for resizing images was published today by Josh Hundley at the bakery. The helper caches the resized image as well so that resize functions aren’t called every time the script is called.

When including this helper it is fairly easy to resize the image in your views.

Just use the following code:

echo $image->resize('myimage.jpg', 150, 150, true);

You can download the helper here

Feb 19

PHP the Smarty Way

Smarty logoWhat is Smarty? It’s a php templating engine. I’ve used Smarty on several projects and I like it’s simplicity. It forced me to keep my application logic separated from the presentation code. This is a must when organizing your code. The last thing you want is your designer browsing through hundreds of lines of code just to apply some html. Furthermore, Smarty comes with extra features such as built-in caching, vairable modifiers, filters, and much more including user contributed plugins.

How to install Smarty

Installing Smarty is a fairly simple process. I will break the installation process into 3 steps.

STEP 1 - Download and Extract
Grab the latest Smarty release from Smarty’s download section then extract the package into your application directory. Now rename the new directory created by the archive from “Smarty-x.x.x” to “smarty” for the sake of simplicity.

STEP 2 - Create required folders

Smarty requires some folders for caching purposes among other things. In your smarty directory create the following folders:

/path/to/application/smarty/cache
/path/to/application/smarty/configs
/path/to/application/smarty/templates
/path/to/application/smarty/templates_c

Then change the permissions of the newly created cache and templates_c folders to 755

STEP 3 - Create the smarty setup file

Create a file called smarty.php and put this wherever your application configuration folder is located. You’ll want to include this file in your application php files. So if you use a global index.php file or configuration file include it in there.

Here’s the following setup code for smarty.php

// put full path to Smarty.class.php
require('/path/to/application/smarty/libs/Smarty.class.php');
$smarty = new Smarty();
 
$smarty->template_dir = '/path/to/application/smarty/templates';
$smarty->compile_dir = '//path/to/application/smarty/templates_c';
$smarty->cache_dir = '/path/to/application/smarty/cache';
$smarty->config_dir = '/path/to/application/smarty/configs';

That’s it. Now whenever you want to display a template file, you’ll need to create that file in your templates folder (ie: /path/to/application/smarty/templates/index.tpl) and then you would call this template from your php file with the following code

$smarty->assign('title', 'Hello World'); // creates a variable 'title' with the string "Hello World" in your template file
$smarty->display('index.tpl');

In your template file you can access the title variable using the following syntax: {$title}
This is a fairly simple way to get started with Smarty.

Here is a crash course on using this engine from the Smarty website - Smarty Crash Course

If you’re already familiar with Smarty, here’s a handy cheat sheet from somewherein.

One last thing. If you’re a CakePHP user I don’t really recommend using Smarty because CakePHP’s template system is much more convenient, nonetheless, there is a way integrate Smarty with CakePHP. Read the article at the bakery.

Feb 10

Windows Apache MySQL PHP (WAMP)

There’s a few WAMP packages out there that make having a php web server on windows as simple as installing a program. I started off using Xampp from apachefriends.org but I had problems running cakePHP with it. Both Xampp and CakePHP have made many improvements since then and they are now compatible with each other. However, when I had problems I switched to WAMP5 from wampserver.com.

In terms of features, both packages are similar. However, Xampp offers SSL support and WAMP5 does not. WAMP5, on the other hand, is lightweight and about half the size of the Xampp package. You can also add SSL support for WAMP5 by following this tutorial.

Wiki has a nice article comparing all of the main WAMP packages out there. Read more

Download WAMP5 | Download XAMPP

« Previous PageNext Page »