Adding a custom resource type to the Zend Framework autoloader

PHP, Zend Framework
Because I can never remember how to do this and because it's not that easy to find on google I have copied the info here. If you want to add a folder to the application directory and then have classes within that directory autoload, for instance you add a folder 'objects' (application/systems) that contain classes like Application_System_One. This would work for any Application_ classes and its exactly what the Zend Framework autoloader does when it inits the default resorces like application forms, models, services etc. Here's what you need to do: Full credit goes to http://pietervogelaar.nl/ for this copy and paste. This week I wanted to created the folder "application/grids/" to store my grids in. For example the path to the grid is "application/grids/Product.php". The code inside this PHP file:…
Read More

PHP MSSQL & PDO_DBLIB (FreeTDS) support on Mac OSX 10.9 Mavericks

Mac, PHP
So since upgrading to Mavericks I have lost the ability to use PHP's MSSQL and PDO_DBLIB database extensions. I had previously set this up on Lion/Mountain Lion. You'll need to download the latest Xcode from the Mac App Store and then run it and install the command line tools. This will allow you to build the packages below. We'll also need autoconf so download the latest source at autoconf-latest.tar.gz. At the time this article was published the latest release was v2.69. Extract this and then using terminal navigate to the extracted source directory and run the below commands: [crayon-6772b255458b2320949379/] Now on to FreeTDS, this is the library that will connect to MSSQL. Visit this link to get the latest stable version of FreeTDS: freetds-stable.tgz. At the time this article was…
Read More

Using syslog for your PHP application logging

Linux, Mac, PHP
In the past I have created custom log files for my PHP applications, mainly because I'd never bothered to read up on syslog and I wasn't using it for major stuff. This time I decided to do the reading and syslog really does have lots of benefits and is just as quick to set up as custom logging. Anyway, I found this nice overview and examples of how you can use syslog with your application. Check it out - Using syslog for your php applications
Read More

Looking back

Life
It's been a good while since my last post and as I look back over the posts I've made I realise that in only one post have I actually talked about coding. The post I am talking about is the one on using PHP and Curl to login to a website to download content. The rest of the posts have been about troubles I've had while setting up my dev environment on OSX lion. While this info has already been useful to some people and probably will continue to help people it wasn't really the reason that I set up the blog. As I learnt new things I wanted to share them but unfortunately due to various things (one being a new role) I have been very busy and haven't…
Read More

PHP memcached on OSX Lion

Mac, PECL, PHP
Having set up the PHP memcache extension on my mac yesterday I now need the PECL memcached extension to use with Zend_Cache. This one was a little more involved than yesterday so here is a quick list of things you'll need to do. My first instinct was to use PECL to get the extension but doing that told me that there was an unmet dependancy so it couldn't be installed. The missing dependancy was libmemcached, here's what you need to do to get libmemcached setup: First go to https://launchpad.net/libmemcached/+download and download the latest libmemcached (1.0.4 at the time of writing), once downloaded extract the archive and then open up a terminal window and cd to the new libmemcached-1.x.x directory. Now enter the commands below into the terminal window one at…
Read More

PHP memcache extension on OSX Lion

Mac, PECL, PHP
Today I needed the PHP memcache extension on my Mac OSX Lion 10.7.3 development machine for a project I'm working on. I was pleased to find out that this was a nice and easy one to get up and running. Open up a terminal window and run the command below, this will tell PECL to download, build and install the extension. [crayon-6772b25546499681572355/] Now that the extension is installed on your system, you need to enable it in your PHP configuration file. On a standard system the php.ini file can be found at /etc/php.ini. Open the file and scroll down to the extensions section, at the bottom of this section add the line extension=memcache.so and then save and close the file. After that, all that is required is for you to…
Read More

PECL UUID extension on Mac OSX

Mac, PECL, PHP
Today I needed to set up the PECL UUID PHP module on my Mac OSX 10.7 Lion development machine, I needed it for a project that I'm working on. My first reaction was to fire up terminal and run sudo pecl install uuid. It all looked good for a moment but then came to a grinding halt when 'make' failed. Here is the error for reference (and for those searching snippets of it): [crayon-6772b2554840b734904855/] After a bit of googling I found out what the problem was and a solution to it. The full explanation and solution can be found here: https://wp.michaelleo.com/2010/04/mamp-pecluuid-module-working-on-snow-leopard/ I can confirm that the patch and build worked on my set up (OSX 10.7 Loin) and I hope by spreading the word it some more people out.
Read More

Installing and setting up PEAR

Mac, PHP
This post will help you get PEAR installed and up and running on your machine, there are two options to below, one describes an OXS Lion specific setup and the other is more generic. Installing on OSX 10.7 Lion OSX Lion already has the PEAR install bundle so there is no need to download it, open up a terminal window and enter the following commands: [crayon-6772b25549139158002248/]   Downloading and installing Do not follow this part if you have just done the above steps. Otherwise enter the below into a terminal window: [crayon-6772b2554913f977495862/] It will ask you to enter a new installation base ($prefix). I recommend you use /usr/local   Configuring PHP include path Edit /etc/php.ini and find the line: ;include_path = ".:/php/includes". Uncomment it (remove the ; at the beginning) and add the PEAR path to…
Read More

Install MySQL 5.1 Server on OSX Lion

Mac, MySQL
So I had to get MySQL set up on my OSX Lion MacBook Pro after the recent format and upgrade to Lion. It was easier than i expected but I thought that it was still worth a post anyway. First off, head over to the MySQL site and download the Mac pre-compiles binary of MySQL Community Server 5.1.x (the latest download says it's for OSX 10.6 Snow Leopard but it works fine with 10.7 Lion). Download the latest DMG available, this can be found here http://dev.mysql.com/downloads/mysql/5.1.html. When the download finishes, open the disk image and install the main package file (mysql-5.1.xx-osx10.6-x86_64.pkg), when that finishes double-click on the preferences pane (MYSQL.prefpane file) file to install that into the System Preferences menu. If you would like the database server to start on boot then…
Read More