Understanding LARAVEL

Understanding LARAVEL

16 Nov. 15
2.86 K VIEWS

PHP is most widely used scripting language to drive the web. It evolved a lot with frameworks and now its almost equal to any object based language with latest version. One great framework for PHP has been LARAVEL, which has given heights to PHP by naming “PHP for web artisans”.

What is LARAVEL?

Laravel is a clean and classy framework for PHP web development. Freeing you from spaghetti code, it helps you create wonderful applications, using simple, expressive syntax. Development should be a creative experience that you enjoy, not something that is painful. Enjoy the fresh air!

The author Taylor Otwell says, Laravel strives to bring back the joy to programming by making Laravel simple, elegant, and, most importantly, well-documented. Yes, it is. During our course of development we found LARAVEL

Simple – easy to understand and implement.
Elegant – relies on industry driven standards thus less code-bloat.
Well-documented – Its well documented, What Taylor and laravel team does at best is to create proper documentation before releasing a new version of LARAVEL.

Why it’s different?

There are many positives to support this statement, here are few of them –

Bundles – That is key for laravel. Bundles for LARAVEL is like PEAR for PHP. Bundles are add-on packages which can be added to your laravel installation. Laravel provides artisan commands which make it very easy like –

php artisan bundle:install NAME

Eloquent ORM – Similar to Doctrine ORM (of symphony) , it makes any work on database records simple and easy. It abstracts most functions that you’ll have on models (i.e. CRUD operations) and provides a flexible way to add more. Additionally, the Eloquent ORM gives you the ability to define model relationships to retrieve records, based on their relationship to another record. See below how simple it is to get all files of user –

foreach( $user->Files as $file ) {
echo $file->name;

Migrations – they are great utility, with multiple developer environment it makes very easy to have database schema up-to date; they can be executed via Artisan command utility. As per documentation it’s pretty clear –

Schema::table(‘users’, function($table)

It also provides possibility to rollback schema from up() & down() functions.

Unit Testing – Its feature reach to support TDD i.e. Test Driven Development, Laravel’s own beautifully integrates with PHPUnit, relying on its status as one of the industry’s best PHP unit testing frameworks. To build a test, simply extend the PHPUnit_Framework_TestCase class, like so:

class MyUnitTest extends PHPUnit_Framework_TestCase
public function somethingShouldBeTrue()

Redis – Redis is a key value data store like CouchDB / MongoDB. Redis support in Laravel is executed so elegantly to the point that I can’t even begin to describe how easy it is to get up and running. We only need to add some settings in database.php & then calling it pretty simple

redis = Redis::db(); //this gets a Redis object connected to the ‘default’ configuration
$redis = Redis::db(‘LNTest’); //this gets a Redis object connected to the ‘staging’ configuration
$redis = Redis::db(‘LNProduction’);
//Above does a Redis object connected to the ‘production’ configuration

$site = $redis->get(‘site’);
$sites = $redis->lrange(‘sites’, 0, -1);

Installing Laravel 5 and first Project

Let’s Start with the basics such as installing Laravel 5 and then configuring it so that we can begin development.

Installing Composer:
Laravel 5 needs to have composer installed. Navigate to https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
and follow the instructions to install composer.

Our Project – Create & Serve
Once you’ve successfully installed Composer, navigate to your terminal and use:
composer –version

After this move onto creating Laravel 5 project. This can be done via composer install by typing into the command line, navigate to where you wish to store the project and type the following into the terminal:
composer create-project laravel/laravel PROJECT-NAME –prefer-dist

This will create basic Laravel 5 application in the folder “PROJECT-NAME”. ‘cd’ into this new folder and then type the following to start running our new project.
php artisan serve

Navigate to localhost:8000 in browser and you can see the Laravel 5 welcome page. Congratulations you have successfully created a Laravel 5 project and now begin work on our content management system/blog or whatever we have created.

Running Our Project on Another Port:
If for some reason port 8000 is already in use then you can specify what port you wish your laravel 5 app to run on just add flag to your command:
php artisan serve –port=8001


Lets Nurture
Posted by Lets Nurture


Have an !dea or need help with your current business?

For immediate assistance in sales or support, please call us on:


We use cookies to give you tailored experiences on our website.