Reputation: 37
I'm using Leaf PHP. I'm trying to simply create a controller (using php leaf g:controller dsos) which worked.
class DsosController extends Controller
{
public function index()
{
response()->json([
'message' => 'DsosController@index output'
]);
}
}
Now, I want to create a route to this controller as htts://myserver/Dsos. So, in /app/routes/_app.php, I added this line:
app()->get('/dsos', 'DsosController@index');
But it does not work (error 404). Any help will be appreciated,
Thanks
Upvotes: 1
Views: 373
Reputation: 1
I think you should check your file naming or directory structure. DsosController class should be located in a file named DsosController.php within the appropriate directory based on the namespace
Try this code
/app/routes/_app.php,
use App\Controllers\DsosController;
app()->get('/dsos', DsosController::class . '@index');
Upvotes: -1