Open shubiourShuvo opened 2 years ago
PHP 8.1 does not accept non-static methods without callback so you have to change the following in the Router.php Or you can downgrade your version to 7.4
$router->get('/products', [ProductController::class, 'index']);
But it accepts;
$router->get('/products', [new ProductController(), 'index']);
Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method app\controllers\ProductController::index() cannot be called statically in D:\XAMPP\htdocs\php-crash-course-2020-final-version\14_product_crud\03_good\Router.php:53 Stack trace: #0 D:\XAMPP\htdocs\php-crash-course-2020-final-version\14_product_crud\03_good\Router.php(53): call_user_func(Array, Object(app\Router)) #1 D:\XAMPP\htdocs\php-crash-course-2020-final-version\14_product_crud\03_good\public\index.php(20): app\Router->resolve() #2 {main} thrown in D:\XAMPP\htdocs\php-crash-course-2020-final-version\14_product_crud\03_good\Router.php on line 53