Ad

Getting This Error "syntax Error, Unexpected 'echo' (T_ECHO), Expecting ';' " In Laravel While Creating Simple Controller

- 1 answer

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","[email protected]");" 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";
    }
}
Ad

Answer

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

You just included namespace.

Ad
source: stackoverflow.com
Ad