I'm trying to host my website; it works fine on my VS code but when I hosted it and run it gave me this error.
I'm using php - lumen framework.
[28-Nov-2023 13:12:17 UTC] PHP Warning: Undefined variable $router in /home/xx/portfolio/routes/web.php on line 16
[28-Nov-2023 13:12:17 UTC] PHP Fatal error: Uncaught Error: Call to a member function get() on null in /home/xx/portfolio/routes/web.php:16
I'm new to php overall and to the framework itself.
this is my code on web.php
<?php
/** @var \Laravel\Lumen\Routing\Router $router */
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$router = app('router');
$router->get('/', function () use ($router) {
return view('portfolio');
});
$router->get('/blog', function () {
return view('blog');
});