A
A
architect4042021-10-29 09:01:53
symfony
architect404, 2021-10-29 09:01:53

When opening a site on Symfony, it gives an error SymfonyRuntime?

When you first start the site on Symfony, it gives an error:

Argument 1 passed to Symfony\Component\Runtime\SymfonyRuntime::getRunner() must be an instance of Symfony\Component\Runtime\object or null, instance of App\Kernel given...

I created a project on symphony through composer, all I changed in it was that I registered in .htaccess a redirect to the /public folder and "platform-check": false in composer.json so that it would not swear at the php version. Everything. It should show a welcome screen on first run, but it shows an error. A search in the documentation or on the Internet turned up nothing.
My index.php
use App\Kernel;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function (array $context) {
    return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};

Even if you copy-paste other examples from the documentation, for example
use Symfony\Component\HttpFoundation\Response;

require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

return function () {
    return new Response('Hello world');
};

then I get the same error:
Return value of Symfony\Component\HttpFoundation\Response::setStatusCode() must be an instance of Symfony\Component\HttpFoundation\object, instance of Symfony\Component\HttpFoundation\Response returned

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
architector404, 2021-10-29
@architect404

It turned out that my domain had an outdated version of 7.1, not 7.3. It was necessary to just update the php version, and not write "platform-check": false
Special thanks to Anton for giving me the idea to double-check the php version

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question