thecodeholic / php-mvc-framework

PHP MVC Framework
https://www.youtube.com/playlist?list=PLLQuc_7jk__Uk_QnJMPndbdKECcTEwTA1
478 stars 180 forks source link

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

Open ERP-Academia opened 3 years ago

ERP-Academia commented 3 years ago

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()

thecodeholic commented 3 years ago

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