Conor Conor - 2 months ago 20
PHP Question

Starting of laravel in windows



I have recently started using laravel

I have searched a lot and found many help how to start a project in laravel.

I am using windows 64bit and xampp

As per the guide from Larvel and Turtorialspoint I have figured out how to start using laravel.

Fisrt Install

composer
then install
laravel
and then create a project

I have first installed composer using composer-install.exe which is available in laravel site.

I run that setup and installed it in
C://xampp/php/php.exe
.

Then I run the code
composer create-project laravel/laravel laravel
on the location
C://xampp/htdocs


I got the project installed successfully..... :)



enter image description here

Then i run it in local host by the following code
php artisan serve


It gave me an localhost link which lead me too:

enter image description here
It was according to the instructions from tutorialspoint.
But there Laravel was not like this.(not a matter)

And when i searched further i cant understand anything.

They have completely different files(some) and the codes are very different.

Please someone guide me how to do an "Hello World" Example in it.
Thanks


And i found
app/HTTP/routes.php
missing! Please find it also.


enter image description here

Answer

I think this would be a good reference for you.

According to Laravel, you can define your routes inside web.php file under routes\web.php folder

Your views would be under resources\views folder

Create a controller using command line. php artisan make:controller Welcome

Edit your controller file and edit the generated code.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

class Welcome extends Controller
{
    //

    public function index() {
      $data = array('name'=>'Conor');
      return view('hello',$data);
    }
}

Create a view manually if not present inside resources\views\hello.php

<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <title>Hello <?php echo $name; ?></title>
    </head>
    <body>
        <h3>Hello <?php echo $name;?></h3>
    </body>
</html>

Edit App\routes\web.php and add the following code Route::get('/welcome', 'Welcome@index');

Now run php artisan serve