1

I have created the new controller using command line on laravel

php artisan make:controller PhotoController --resource

just display the string on a function of PhotoController like below

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PhotoController extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function getName()
    {
        echo 'Dev';
    }

Called the controller on route web.php

Route::get('photos', 'PhotoController@getName');

When i trying to load the url of controller

http://localhost/dev_laravel/public/photos

getting 404 Not found error

I also tried

http://localhost/dev_laravel/public/photo/
http://localhost/dev_laravel/public/photo/getname/

I'm beginner or learner for laravel and working on 5.8 version

php artisan route:list

after

enter image description here

Can anyone help me?

2 Answers2

1

Open Terminal and Run This Command

php artisan serve

Open Second Terminal and run this command

php artisan route:list

And then Your url pattern is like

http://localhost:8000/photos or

http://127.0.0.1:8000/photos
Zahid Hassan Shaikot
  • 1,066
  • 10
  • 18
Arshit
  • 118
  • 2
  • 7
0
php artisan serve

it gives a link like http://127.0.0.1:8000/ or your desire port if you set a port for it then just add photos like

http://127.0.0.1:8000/photos

albus_severus
  • 3,626
  • 1
  • 13
  • 25