Table of Contents
1. Introduction
2. What is a PHP framework?
3. What is Laravel and why should I use it?
4. Setting up your PHP environment
5. Installing Laravel
6. Hello world with Laravel
7. ...more as time goes on.
----------------------------------------------------------
1. Introduction
----------------------------------------------------------
This is going to be a series of tutorials that will gradually unfold and hopefully at the end (depending on the response) you will all see the benefits of using Laravel, an awesome PHP framework.
In this tutorial, I will assume everyone reading this has a fair knowledge of PHP and can comfortably write PHP scripts. So lets get started. If yoyu haven't already, set up your local web server. Download a copy of Laravel from their website.
If you have done set up your web server on localhost and have a compressed zip of the Laravel framework, lets start. Please note that the tutorials will be strongly based on L3 (Laravel v3.x) so please make sure you have the right version.
----------------------------------------------------------
2. What is a PHP Framework
----------------------------------------------------------
Lets take a quick detour here and quickly define what a PHP framework is. A PHP framework is essentially a collection of PHP classes and libraries, coupled together to make application development faster and smoother.
In layman's words, PHP frameworks speed up development time because it has classes and functions that help you do tasks quicker and safer. Take for instance, some Frameworks come shipped with a database class that essentially makes fetching data from databases easier and faster, makes table-to-table relationships easier to achieve. There are also caching classes, authentication classes, request classes, inbuilt clean URL structures etc. things tat you would have taken a lot of time to code from scratch.
If you want to know more about php frameworks, i'd suggest you dig deeper.
----------------------------------------------------------
3. What is Laravel and why should i use it?
----------------------------------------------------------
According to their website: "Laravel is a clean and classy framework for PHP web development. Freeing you from spaghetti code, Laravel 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 reasons you should use Laravel is the same reason why anyone will want to use a PHP framework in the first place: quick and safe development. Laravel provides an easy to use layer of libraries that just takes the pain away from developing apps. Literally in my first three days of learning Laravel, i had already started developing web apps.
Laravel is very expressive, Just by reading the source code you can understand everything the code is trying to do. Take for instance this block of code from the frameworks core, i have stripped the comments out of it, now see if you understand this code without the commenting:
PHP Code:
class Str {
protected static function encoding()
{
return static::$encoding ?: static::$encoding = Config::get('application.encoding');
}
public static function upper($value)
{
return (MB_STRING) ? mb_strtoupper($value, static::encoding()) : strtoupper($value);
}
}
Every of Laravel's classes that seem to have normal php functions e.g session, cookies etc have added benefits. For instance, the Session class that comes with Laravel allows you easily store sessions on databases, also other session storage methods. The cookies class implements secure hashing to prevent some unnecessary holes in your application. So, bottom line, if Laravel has a class for it, use it.
Comment