0
votes

I have just uploaded my Symfony (2.7) project online and I have a 500 error happening only online in prod environnement (app.php). I have set $kernel = new AppKernel('prod', true); in app.php file in order to see the error message:

Error: Cannot use object of type Symfony\Component\HttpFoundation\Request as array
in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/EventListener/RouterListener.php at line 143

}
if (null !== $this->logger) {
    // Below is line 143
    $this->logger->info(sprintf('Matched route "%s".', isset($parameters['_route']) ? $parameters['_route'] : 'n/a'), array(
        'route_parameters' => $parameters,
        'request_uri' => $request->getUri(),
    ));

(This file is part of Symfony, see complete code here.)

In local (WAMP), I have no issue using app.php or app_dev.php . Online, app_dev.php is working well but when try to access http://mydomain.fr/web/, I have this error.

I am a bit lost here, if you need more information, just ask me which file or else I should copy in this question.
Just to see what happens I commented the logger line in RouterListener.php, I have another different error showing. I guess there's something wrong with my server's config or something like that... but I have no idea what I should look at.

1
I'm pretty sure your $parameters variable is actually Request object. - Igor Pantović
You have to show us full method code, not just the problematic line. - Igor Pantović
github.com/symfony/HttpKernel/blob/2.7/EventListener/… But I don't want to (and don't think I have to) change this file, it's part of Symfony. Though it might help understand what the problem is. - user3849602

1 Answers

1
votes

Some controller code is trying to access values by keys on an object as if it were an Array;

<?php

$moo = (object) ['foo' => 'bar' ];
/* run-time error below: */
$moo['foo'];

This happens when you upgrade "the library" or API without updating client code. It happens also when client code (your code) confuses the order of parameters in function invocations.