– Fix ‘Could not find driver’ issue

If you installed on a Mac, you’ll often get a ‘could not find driver’ error. This happens because the PHP extensions for Postgres is not loaded in your configuration.

The simple solution is to add the extensions to your php.ini file.

If you don’t have the extensions (or don’t know the location) you need to download and compile the extensions.

To do that,

1. Go to the PHP website and download your version of PHP (yes, you need to download PHP again).

2. Extract the contents on the archive. Then open the terminal and run the following commands.

Go to the downloaded path, and then the extension directory.

This will compile and copy the new extensions to your PHP’s extensions directory.
After that, update the php.ini file as listed above, and restart Apache.

The above instructions are to compile the PDO extension, which is mainly commonly used in Laravel and other frameworks. If you need the non-PDO extension, repeat the instructions above by moving to ‘ext/pgsql’ directory.



Steps to Install Laravel 4 in a Shared Hosting Account

Here is an easy way to install your Laravel 4 application on a shared hosting account, such as Hostgator.

You can use SSH and install Laravel through Composer. Alternatively, you can just upload the files through an FTP client.

There are many ways arrange the files. Here’s one approach you can take.

  1. Copy the contents of your local ‘/public/’ folder to ‘/public_html/’ folder on server.
  2. In your server, go down one level, (eg. if you’re in /public_html/, do down to / and create a new folder. We’ll place all the Laravel files in this folder. Let’s name it ‘/laravel/’
  3. Copy the contents from your local Laravel folder into the new ‘/laravel/’ folder on server. (Since we have already copied the ‘/public/’ folder in the Step 1, it can now be ignored)
  4. In your ‘/public_html/index.php’ file, make the following changes.
    Look for the two lines below, 

    and change them to,
  5. And in your ‘/laravel/bootstrap/paths.php’ file, make the following change.
    Look for the line below, 

    and change it to.

Now everything should be working right. All we did was, just renamed the ‘/public/’ folder and moved all the Application files to a separate folder. This is a good security practise, since it puts all the application files out of the public_html folder.

In summary, the file structure on the server will look like this.

Still issues getting it to work? Drop a comment below.

How to Install Laravel 4 on a Hostgator Shared Hosting Account

You can easily get Laravel 4 running on a shared hosting account by just uploading all the files to the server. But just make sure to map the domain (or sub-domain) root the the ‘public/’ directory of Laravel.

If you have an old Hostgator account, you may see the following error when you try to launch the site.

Warning: require(__DIR__/../bootstrap/autoload.php) [function.require]: failed to open stream: No such file or directory in /home1/[YOUR_USERNAME]/public_html/[YOUR_PROJECT_DIR]/public/index.php on line 21

Warning: require(__DIR__/../bootstrap/autoload.php) [function.require]: failed to open stream: No such file or directory in /home1/[YOUR_USERNAME]/public_html/[YOUR_PROJECT_DIR]/public/index.php on line 21

Fatal error: require() [function.require]: Failed opening required '__DIR__/../bootstrap/autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home1/[YOUR_USERNAME]/public_html/[YOUR_PROJECT_DIR]/public/index.php on line 21

A common reason for this is a PHP version mismatch. If your Hostgator account is created before 16 May, 2013, you’re likely to have an old PHP version installed. Hostgator has the latest PHP on server, but it needs to be activated through your /public/.htaccess file.

To do that, open your /public/.htaccess file and add the following two lines on the top of the file.

Hopefully this should get things working. If not, try to leave a comment below.

jQuery Table Plug-in Review – jqGrid

After going through a lot of options to select the best jQuery table/grid plug-in, I’ve finally chosen jqGrid.

It has a lot of flexibility and built-in options for most of the common requirements, such as.

  • Sorting
  • Pagination
  • Search (on both client and server)
  • Filters
  • In-line editing
  • Live syncing with server
  • Categories within tables (grouping into sub-tables)
  • and much more…

You can view a live demo of the jQuery table plug-in here. It’s free, open-source and actively maintained. It uses jQuery UI, so you can change the theme easily to match with the rest of your application.

Here is the project home page where you can get downloads, documentation and updates.


MAMP MySQL Won’t Start? – How to Fix the MySQL Server Issue in MAMP

If you get the message “Error: Could not connect to MySQL server!” or if you have trouble starting up or restarting the MAMP Server with MySQL, you can try the following solution.

  1. Quit MAMP
  2. Open Terminal window
  3. Type “killall -9 mysqld” and press enter
  4. Start MAMP
  5. Start servers

This fixed the issue I was having with the MySQL server starting up on MAMP.