-1

Just started learning laravel I tried to create a route for my view but when I load on the web browser it says Sorry, the page you are looking for could not be found. Can any one help me out in codeigniter it was so simple just create a controller and view and we can see on the web broswer I found laravel to be difficult then codigniter is that true?? can anyone define me how is the mvc structure for laravel5 as i found tutorials but they are of old laravel and files and structure are almost change so I got confused any suggestions please

routes.php

Route::get('main', 'Main@index');

Main.php

namespace App\Http\Controller;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;


class main extends Contoller {
    public function _construct() {
        $this->middleware('guest');
    }

    public function index() {
        return "Hello World from controller";
    }
}
Mark Alan
  • 435
  • 4
  • 15

4 Answers4

1

if you are running laravel project locally, it can run through its own server. you dont need apache server form wamp or xampp,,but you will need their mysql database. So start only that if you require database.

Now go to command prompt, navigate to the directory where your project is stored eg cd c:/wamp/www/yourprojet and then type following command

php artisan serve

it will start on port 8000 by default. and you can now access your project at 'http://localhost:8000/'

and you can access your view at 'http://localhost:8000/main'

Also you can find laravel tutorials and other at laracast

SJB
  • 193
  • 1
  • 1
  • 9
0

Try to change the class name to Main (now is main, in lowecase)

I learnt Laravel by their awesome tutorial: https://laravel.com/docs/4.2/quick

Nil Llisterri
  • 644
  • 6
  • 19
0

make a view in resources->views, something like my-view.blade.php

Then return view('my-view');

That my-view.blade.php can have whatever HTML you want in it

Devin Gray
  • 1,710
  • 4
  • 19
  • 35
0

Go to your resources/views folder create file with filename.blade.php.

Now in your routes.php:

Route::get('main', 'Main@index');

And in your controller add this function:

public function index() {
    return view('filename');
}
leek
  • 10,883
  • 7
  • 40
  • 59
Kroonal
  • 290
  • 2
  • 6