Friday, 2 May 2008

Zend and MySQL

Zend currently uses the Pear library to do stuff with DBs. Whereas installing this library may be fine, you might not have access to the server to install more stuff. Instead, follow this article about Adding adapters to Zend which allow it to use PHP. Alternatively, get the latest source files here and put the Php directory within Zend/Db/Adapter/. It works a treat, just remember to set the connection type to php_mysql as opposed to pdo_mysql

None of this is my own work. It all belongs to David Coallier (davidc@agoraproduction.com) and his blog http://blog.agoraproduction.com. Awesome job, thanks.

Apache mod_rewrite refusing to work

Apparently, some servers require FollowSymLinks to be turned on. If mod_rewrite is refusing to work and just denying all access (particularly important when trying to implement MVC with a bootstrap file) try including this in the .htaccess file:
Options +FollowSymLinks

More cool stuff with http.conf

Ok, I'm getting there. I know know a bit more about Apache's VirtualHost directive:

DocumentRoot /var/www/phpweb20/htdocs

This gives an absolute path to the directory where your web files will be served from. It can be anything you want.

<Directory /var/www/phpweb20/htdocs>
AllowOverride All
Options All
</Directory>


This says, for a given directory (and it says which in particular with the path) AllowOverride which allows me to use .htacess files in that folder. Not too sure what Options does yet.

The other cool bit is this line:

php_value include_path .:/var/www/phpweb20/include:/usr/local/lib/pear

This tells the PHP module in Apache where to look for include files. Pretty handy.

Thursday, 1 May 2008

PHPDoc

Use PHPDoc rules for formatting:


/**
* functionName
*
* Brief description of the function. What it DOES,
* not how it does it
*
* @param string $name The name of the user
* @param int $age The age of the user
* @return string The generated welcome message
*/
function functionName($name, $age)
{
...
}

Pretty simple really.

Debugging Google Maps Apps

Check out GLog.

Back ticks

you can call UNIX commands in PHP by putting commands in back ticks (`). Similarly, shell_exec('...'); will run scripts too.


popen() is also apparently useful, it allows you to open processes and talk to them.

Differences between echo and print

It's all in the single, or double quoting. echo "$variable" will get echo to replace the variable name with it's value. If echo is used with single quotes it won't work.

Also, echo is slightly quicker than print apparently.