Closed mattfletcher closed 8 months ago
Did you create a new instance of the class before? You can check if the class is callable with the PHP is_callable function. If you get false as result, there is no instance of your class, to which flight can point to.
@mattfletcher
Flight requires fully qualified class references. IE: replace Index::class
with Trains\Controllers\Index::class
.
As a last resort, one could disable deprecation warnings.
EG error_reporting(error_reporting() & ~E_DEPRECATED);
EDIT:
Also, the invocation you're using will only work if Index::index
is a static function. If it's not a static function, the first item in the array should be a class instance.
Looks like this also has been done @n0nag0n .
Thanks @krmu
I'm trying to use a simple route, adapted from the docs, to route requests to
/
to a controller method, and I get errors on PHP 8.1. Works on 7.4:NOTICE: PHP message: PHP Fatal error: Uncaught TypeError: flight\Engine::_route(): Argument #2 ($callback) must be of type callable, array given, called in /application/vendor/mikecao/flight/flight/core/Dispatcher.php on line 227 and defined in /application/vendor/mikecao/flight/flight/Engine.php:443