Laravel 4 Bootstrap Site basic setup

Posted on

Hello world!

I will go into details on the first steps I took to have a solid base for the Laravel 4 framework.

Check out andrew13/Laravel-4-Bootstrap-Starter-Site!

I was really happy when I googled this up ^^

I had been looking at a ton of tutorials on Laravel 4 and was about to start coding my way through an auth system, with roles, permissions a user admin management and a blog/products/bananas/item manager.

In this case this starter bootstrap for Laravel 4 has it all!

Check out my previous tip where I posted a bash script to auto install Laravel 4, here si the same script modified for Laravel 4 Bootstrap Site:

#!/bin/bash
# Install laravel 4 bootstrap site and configure
# Call scriptname.sh projectname
# The projectname parameter will be the name of the folder where laravel 4 will be installed.
# 
# This script assumes that your webroot is in ~/www/.
# 
# Check the path for your commands. It is better to use full paths in scripts.
# 
# Read the code once and make sure everything is the same on your system!

echo -e "e[1;34mInstalling Laravel 4 Bootstrap Site into e[1;31m$HOME/www/$1/e[0m"

cd $HOME/www/

echo -e "e[1;34mDownloading master branch from e[1;34mgit://github.com/andrew13/Laravel-4-Bootstrap-Starter-Site.gite[0m"

/usr/bin/git clone git://github.com/andrew13/Laravel-4-Bootstrap-Starter-Site.git $1

cd $1

echo -e "e[1;34mSetting permissions to e[1;31m$HOME/www/$1/app/storagee[0m"

# Make the app/storage directory writable
chmod -R 777 app/storage

# Check if composer is installed globally, if not install it locally.
if hash composer 2>/dev/null; then
    echo -e "e[1;34mComposer is installed globally.e[0m"
    /usr/local/bin/composer install
else
    echo -e "e[1;34mInstalling Composer into e[1;31m$HOME/www/$1/e[0m"
    /usr/bin/curl -s https://getcomposer.org/installer | php
    composer.phar install
fi

echo -e "e[1;34mGenerating application key.e[0m"

php artisan key:generate

echo -e "e[1;34mCleaning up the git.e[0m"

rm -rf .git*

echo -e "e[1;34mLaravel 4 Bootstrap Site installed in e[1;31m$HOME/www/$1/e[0m"

exit 0

Now you need to go and edit your app/config/database.php file, but it would be wiser to first setup environments and local config files.

First open up bootstrap/strat.php

And make your $env look like so:

$env = $app->detectEnvironment(array(

    'local' => array('*.local', 'VirtualMint'),

    'production' => array('*.com'),

));

VirtualMint is my hostname, hit hostname in terminal to know yours. This allows for artisan to know that it needs to look in the local configuration files on the local machine, so you don’t have to type php artisan –env=local everytime.

Now create two new folders in your app/config folder: local and production

Copy the default database.php and mail.php to those folders, if you start changing things to app.php also copy it there before any changes and do the changes in the ones in the right folder, local or production.

Edit app/local/ database.php and mail.php to your local server settings and maybe use a gmail for mail.php. That is what I am trying we’ll see if it works for local dev 🙂

Next it is time to migrate and seed your databases:

php artisan migrate
php artisan db:seed

You also need to make sure your application encryption key is set (php artisan key:generate) and that your app/storage folder is writable by the server (chmod -R 775 app/storage or 777 if that does not work).

The script I posted does both already and chmod -R 777 to be sure it works. No worries on doing that on a local host. I would make sure chmod -R 755 works on your production server as otherwise it would mean permissions are not set right.

Fire up your browser and your skeleton site should be up and running!

Go to /admin to checkout the admin panel.

This is all very straightforward but I am sure it could help someone out and I am selfishly doing it as a way of tracking my progress ^^

Leave a Reply

Your email address will not be published.