0
votes

Hey I just start to learn Laravel. I have created Controller successfully with php artisan make:controller Youtube command. But the thing is when i try to access it from Route which look like this "Route::get("/Youtube","Youtube@index");" While there is simple echo statement in controller. Controller look like this

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Youtube extends Controller
{
    function index(){
      echo "create";
    }
}
2
Add trace. Perhaps this will be a duplicate question. - Mully
Ist that the full file triggering that error? - Nico Haase

2 Answers

0
votes

You can try this code, YoutubeController insted of Youtube. And URL should be lowercase.

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class YoutubeController extends Controller
{
    function index(){
      dd('create');
    }
}
Route::get("/youtube","YoutubeController@index");
-1
votes

Add, use App\Http\Controllers\Controller; before class and make the function as public This should work fine.

You just included namespace.