piusbnsl
308
18
Laravel

Routing in Laravel?

Posted 3 weeks ago by piusbnsl

I am new to Laravel and I was watching laracasts' tutorial. I have a doubt in routing section. I also searched it google but I think I could not frame it properly. So I am trying here.

See, I am using Mac OS Mojave and have setup apache to serve files from Sites folder that I have created in my home directory. Now my laravel project has directory url - ~/Sites/Practice/myfirstsite. So I open Laravel project on chrome as - http://127.0.0.1/Practice/myfirstsite/public/ . As mentioned in tutorial I added another route for "/contact" in web.php and created a contact.blade.php page in views folder. But the problem is I am not able to access that contact page. I am putting this URL in chrome - http://127.0.0.1/Practice/myfirstsite/public/contact .

in web.php -

Route::get('/contact', function(){
    return view('contact');
});

in contact.blade.php -

@extends('layout')

@section('content')
    <h1> Contact Us here </h1>
    <!-- <p> This section is under maintenance. </p> -->
@endsection

Forgive me if I am asking very basic or stupid question. I tried searching on google and could not find it. If any other information is needed, tell me I will put it here.

Edit- I know that the way I am doing is not the right way to do things. Public folder should not be part of URL. I probably should change my document root directory to that of public folder. But my question is more of fundamental type. When I route to "/", http://127.0.0.1/Practice/myfirstsite/public works fine. But when I route to "/contact", http://127.0.0.1/Practice/myfirstsite/public/contact does not work.

Also http://127.0.0.1/Practice/myfirstsite/contact does not work.

Please sign in or create an account to participate in this conversation.