# A Simple Laravel Hello World

DevFeed: [A Simple Laravel Hello World](<https://devfeed.tech/articles/a-simple-laravel-hello-world-28186.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/laravel/2021/05/27/a-simple-laravel-hello-world.html>)

Author: Fuzzygroup

Published: 2021-05-27T13:02:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Laravel](<https://devfeed.tech/topics/laravel.md>), [Composer](<https://devfeed.tech/topics/composer.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [HTML](<https://devfeed.tech/topics/html.md>), [Rails](<https://devfeed.tech/topics/rails.md>)

Tags: [how-to](<https://devfeed.tech/tags/how-to.md>), [laravel](<https://devfeed.tech/tags/laravel.md>), [make](<https://devfeed.tech/tags/make.md>), [mvc](<https://devfeed.tech/tags/mvc.md>), [php](<https://devfeed.tech/tags/php.md>), [route](<https://devfeed.tech/tags/route.md>), [view](<https://devfeed.tech/tags/view.md>)

## AI overview

A step-by-step Laravel tutorial that builds a minimal Hello World application using Composer, a controller, a route, a variable, and an HTML view. It explains that the example demonstrates parts of an MVC framework without covering models or database connectivity.

## Source excerpt

As of late I've been working in Laravel and figuring out how Laravel differs from Rails. And while I have a bigger blog post in the works, I thought there was learning value in a simple Hello World implemented in Laravel. Hello World is a simple program that just puts Hello World on the screen. Here's how I thought a Laravel version of this should work: Be a whole Laravel application Be a single controller Be a single route Define the text "Hello World" as a variable, $text, in the controller Display that on the screen via an HTML template While this doesn't illustrated models and database connectivity, this actually illustrates how to use a surprising amount of an overall MVC framework. Step 1: Creating an Application The first step is to use composer to generate the overall application with: composer create-project laravel/laravel hello_world The next step is to change into the directory with: cd hello_world and then open the code base with: mate . or if you use Sublime: subl . Step 2: Generating a Controller Back at your command line, you want to generate a controller with: php artisan make:controller HelloController This will create a file named HelloController in app/http/Controllers: ls -l app/Http/Controllers total 16 -rw-r--r-- 1 sjohnson staff 361 May 18 11:37 Controller.php -rw-r--r-- 1 sjohnson staff 122 May 27 09:12 HelloController.php Inside the controller you want to add the following code (some of which will already be there from the generator): public function index() { return view('hello_index'); } inside the "class HelloController extends Controller" block of code (it goes inside the {} braces). Step 3: Adding a Route Moving back to the code base, you want to edit the file routes/web.php and add this line: Route::get('/hello', 'App\Http\Controllers\HelloController@index'); This adds a single route, /hello, which is then handled by the Hello controller and the hello_index action. You can test that this route is available by running: php artisan rout