skip to Main Content

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 AppHttpControllers;

use IlluminateHttpRequest;

class PhotoController extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return IlluminateHttpResponse
     */
    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

Answers


  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
    
    Login or Signup to reply.
  2. 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
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search