Essential toolkit for a developer building a site

This is my own opinion of the keys to give you a leg up when creating a new PHP/MySQL site:

  1. Apple Mac – Go to Web Directions and it is clear web developers prefer Macs for many reasons (costs vary)
  2. MAMP Pro – So so good, so easy to use and create local hosts on the local in various locations across your Mac ($US59)
  3. Coda – The best IDE / text-editor for Mac – the all in one window is amazing ($US99)
  4. CodeIgniter – Easy to learn and very fast to develop with PHP framework (free)
  5. CodeIgniter Coda Mode – Code hinting for CodeIgniter within Coda (free)
  6. Twitter BootStrap – Basic front end layout (free)
  7. Font Awesome – Font vector images for Twitter BootStrap (free)
  8. Litmus – Get quick screenshots of your sites (from $US49 p/month)
  9. VirtualBox and Windows IE Testing VMs – Microsoft allows you to download VMs to test your site in different versions of IE (free)
  10. Sequel Pro – Awesome database GUI (free)
And a bonus is the amazing Google Apps – GMail, Google Docs, Google Analytics, Google Web Master Tools, Google Maps…(free for low volume usage)

With these tools you can get started on your next site in hours.

Advertisements

Increasing the PHP Memory Limit

Today I needed to run a some code that did a lot of heavy lifting and kept having the error below:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 71 bytes) in /Applications/MAMP/htdocs/test_memory.php on line 46

The solution is to override the memory limit set by PHP.ini:

<?php
ini_set('memory_limit','64M');

Check out PHP.Net’s ini_set documentation for more details.

Notes:

  • This has be done as one of the first commands in your PHP file
  • You may need to have to increase the limit to more if the problem is still occurring
  • If this is unexpected there may be some really inefficient code in your code base

URL Shortening with CodeIgniter

If you are looking for a fast way to URL shorten with CodeIgniter you are in luck.

Basically you set your routes (application->config->routes.php) $route[‘404_override’] to point to the controller and action which directs shorten URLs

e.g. in you routes file:

$route['404_override']='short_links/retrive';

Then short_links has a function retrive

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Short_links extends CI_Controller {

    function retrive()
    {
        $this->load->model('shorten_urls');//load the model which looks after the URLs
        $url = $this->uri->segment(1);//get the URL segment e.g. abc
        redirect($this->shorten_urls->get_url($url)); //lookup the original URL and redirect
    }
}