php-mvc-framework icon indicating copy to clipboard operation
php-mvc-framework copied to clipboard

PHP 8.0: Calling non-static class methods statically result in a fatal error

Open ERP-Academia opened this issue 4 years ago • 1 comments

Php8 does not accept $app->router->post('/contact', [SiteController::class, 'handleContact']);

It accepts $app->router->post('/contact', [new SiteController(), 'handleContact']);

The problem occurs if you are building the framework following the steps in the video. It is solved later in Router->resolve()

ERP-Academia avatar May 11 '21 21:05 ERP-Academia

The Problem is resolved later, here. You can specify like this $app->router->post('/contact', [SiteController::class, 'handleContact']); and it will create an instance behind

thecodeholic avatar Nov 02 '21 15:11 thecodeholic