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.

http://www.shaneperera.com/blog/

Installing CodeIgniter 2 with Doctrine 2.0

I was struggling for few hours on installing Doctrine 2 with the new version of CodeIgniter. Then I found this excellent tutorial by Joseph on how to install and configure Doctrine 2 with CodeIgniter 2.

If you’re still struggling, here you can download a pre-configured installation with CI2 & D2.
(Please note that there may be new versions out there by now – This will only help you to get the file structure and configuration right.)