An Introduction about Laravel Framework

laravel

About Laravel

Laravel is a very powerful framework, designed for php web application. It will give you ways to modularize your codes and make them look cleaner and easier to read and understand. It is open source software under MIT License.

Features :
Now, we will talk about some prominent features of this framework which make it different from other :
Bundles : These are small packages which you may download to add certain functionality to your web application. Hence, saving a lot of coding stuff and time. These may be containing some custom functionality.
Class Autoloading: It assure that correct components are loaded at correct time and saves a lot of your headache.
View Composer : Theses are block of codes which can run when view is loaded.
Unit testing: Laravel allows user to easily create unit test and run these test making use of Artisan utility.The best thing is it itself supports a number of test to ensure application stability.

In this article we will discuss about a new and very powerful framework in PHP, called Laravel.

Requirements

  • Apache or any other compatible web server
  • Since, Laravel makes use of PHP 5.3 features so it’s also requirement.
  • For detecting file Mime type Laravel make use of FileInfo Library. Windows users must enable this by making appropriate changes to include this extension.
  • It make use of Mcrypt library for security purposes. This library is mostly preinstalled but if you have problems in finding this, then check the vendor site of your LAMP installation

Installation

  • Download Laravel from http://laravel.com/download
  • Extract the Laravel archive and upload the contents to your web server.
  • Set the value of the key option in the config/application.php file to a random, 32 character string.
  • Verify that the storage/views directory is writable.
  • Navigate to your application in a web browser.

Basic configuration

All of the configurations provided are located in your applications config/ directory.Make sure you change the 32 character key inside the application.php inside the config folder. Make the key as any random 32 character string. You may automatically generate key making use of Artisan command utility, which we will discuss later.

Server Configuration

Laravel tends to protect your codes, bundles by keeping only those files that are necessarily public in the web server’s DocumentRoot. This prevents server misconfiguration from getting your codes leaked or accessible to third party.

Environment

Its most likely that the configuration you set for local environment is not same as production. Laravel default environment handling mechanism is URL based, which will make setting up environments very easy. If you open the paths.php from your Laravel installation root directory, you will see the below:

Listing 1: Paths.php

Here, all the url which are starting with localhost and ending with.dev will be considered under local environment. Now if you create a directory local inside application/config then it will override the options in the base application/config directory. You may create as many environment as you like.

Key terms

Models : Models are the heart of your application. It mainly consist of Business Logic. The models mainly comprises of Database interactions, File I/O operations ,Interacting with web services etc.

Libraries : Libraries are classes that perform tasks that aren’t specific to your application. For example a library which can convert your table data to graphs and show that. Creating library is too easy. For eg we create a ShowMess.php with following content and place this inside the library folder:

Now we can call ShowMess::write(“Displaying of text making use of library. This is too simple and easy”) from anywhere in our application which will print “Displaying of text making use of library. This is too simple and easy”.

With Laravel Auto loading feature it is very easy to use both Models and Library.