Install PHP without Apache on Debian

When you go to install PHP on a Debian server, it will attempt to install a whole bunch of Apache packages instead. This is not very useful if you want to install a different web server, or no web server at all.

SilverStripe and PHP version requirements

This post looks at the minimum PHP version requirements for SilverStripe. I will update this page as new versions are released and I upgrade the various SilverStripe websites I manage, noting any issues I experience. Please share also any experiences you have in the comments section at the end of the post. SilverStripe Server Requirements …

Read more

OSX Quick Tip: How to remove automator services

The Automator in OSX allows you to create processes, services, folder actions etc. Once you have created a service in Automator there doesn’t appear to be a way to delete it in the Automater app.

Delete an Automator Service

To delete an automator service, open up the finder and navigate your way to you own Library then Services folder. The files are there with the name you gave it in automater. If the file extension is visible it will be “.workflow”.

So for example, if you created a service to hide dot files and had called it “Hide dot files” then it would show as “Hide dot files.workflow”.

Categories PHP

PHP Quick Tip: use __DIR__ instead of dirname(__FILE__) from PHP 5.3

The traditional way of getting the directory the current file is in with PHP is to use dirname(__FILE__). From PHP 5.3 there is a new magic constant__DIR__ which is the equivilent of this function call.

__DIR__ magic constant

The __DIR__ magic constant is a “magic constant” which changes depending where it is used. It contains the directory of the file it is in. If the file is an include, it is the directory that include file is in. If it is the main script it is the directory that script is in.

__DIR__ is available from PHP 5.3 only. If prior versions a notice will be issued if it is used and the value will be __DIR__ and not the actual directory.

Example error if a version prior to PHP 5.3 is used:

Notice: Use of undefined constant __DIR__ - assumed '__DIR__' in ...

Unless your application requires the use of PHP 5.3 or greater, stick with the traditional use of:

dirname(__FILE__);
Categories PHP

PHP’s heredoc strings

PHP has heredoc syntax similar to other programming and scripting languages which allow multi line strings containing variables to be easily assigned to variables or echoed. This post looks at how to format a heredoc block in PHP and some of the rules.

Categories PHP

Using PHP’s glob() function to find files in a directory

A couple of weeks ago I posted how to read through a directory with PHP using the opendir() readdir() and closedir() functions and now look at the glob() function. glob() returns the filenames into an array and supports pattern matching so it can be very easy to find e.g. jpg images in a particular directory.

Categories PHP