0

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.

3
  • I'm pretty sure your $parameters variable is actually Request object. Commented Sep 20, 2015 at 15:24
  • You have to show us full method code, not just the problematic line. Commented Sep 20, 2015 at 15:25
  • 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. Commented Sep 20, 2015 at 15:28

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I don't understand what you mean by upgrading "the library". (I didn't upgrade anything concerning Symfony.) Online server has an older PHP version (5.4) than local (5.5). Does it have any influence? Why does it work with app_dev.php and not with app.php then?
Hi, sorry it took me long (didn't have time for tests earlier today). I upgraded my PHP version on prod server and it fixed my problem. I'm not sure that's exactly what you meant in your answer but it is related so I accept it.
"The library" would be the symfony package (whole vendor folder) in this case. I did not mean PHP.
Hm well, this wasn't my problem here (I copied the vendor files from my local computer to my online server via FTP) but it could have been. Anyway you made me think to check my PHP versions so you helped, thank you! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.