How Laravel Framework works?


Maybe pulling out a few highlights of what separates Laravel Framework from other frameworks in the space. You’ve already called out community and emphasis on the individual Laravel developer, anything else?

See how it works

Up until now, everything I’ve shared here has been entirely abstract. What about the
code, you ask? Let’s dig into a simple application so you can see what working with
Laravel day-to-day is actually like.

Let’s look at

Hello, World
Example 1-1. “Hello, World” in routes.php

// File: app/Http/routes.php

< ?php Route ::get('/', function() { return 'Hello, World!' ; });

If you initialize a brand new Laravel application on your machine, edit the

app/Http/routes.php file and make it look like the preceding example, and then serve the site
from the public directory, you’ll have a fully functioning

Hello, World


It looks very similar to do the same with controllers:

Example 1-2. “Hello, World” with controllers

// File: app/Http/routes.php
< ?php Route ::get('/', 'WelcomeController@index'); // File: app/Http/Controllers/WelcomeController.php

class WelcomeController
public function index()
return 'Hello, World!';

And if we’re storing our greetings in the database, it’ll also look pretty similar (see
Example 1-3).
Example 1-3. Multi-greeting “Hello, World” with database access

// File: app/Http/routes.php
< ?php Route::get('/', function() { returnGreeting::first()->greeting_text;

// File: app/Greeting.php

< ?php use Illuminate\Database\Eloquent\Model; class Bio extends Model { protected $table = 'greetings'; }

// File: database/migrations/2015_07_19_010000_create_greetings_table.php

< ?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint;

class CreateGreetingsTable extends Migration
public function up()
Schema::create('greetings', function (Blueprint $table) {

public function down()

few lines of code, we’ve set up database migrations and models and pulled records
out. It’s just that simple.