Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Method "request" for object "Silex\Application" does not exist #64

Closed
mrohnstock opened this issue May 27, 2015 · 1 comment
Closed

Comments

@mrohnstock
Copy link

My composer.json:

...
"require": {
        "php": ">=5.5.9",
        "silex/silex": "~2.0@dev",
        "silex/web-profiler": "~2.0@dev",
        "symfony/browser-kit": "~2.6",
        "symfony/class-loader": "~2.6",
        "symfony/config": "~2.6",
        "symfony/yaml": "~2.6",
        "symfony/console": "~2.6",
        "symfony/css-selector": "~2.6",
        "symfony/debug": "~2.6",
        "symfony/finder": "~2.6",
        "symfony/form": "~2.6",
        "symfony/monolog-bridge": "~2.6",
        "symfony/process": "~2.6",
        "symfony/security": "~2.6",
        "symfony/twig-bridge": "~2.6"
},
...

On requesting any route in dev, silex responses with:

Twig_Error_Runtime in Template.php line 485:
Method "request" for object "Silex\Application" does not exist in "@WebProfiler/Profiler/base_js.html.twig" at line 208

I think symfony/symfony#14217 broke something, because I updated all dependencies today, before everything worked flawless. Did I missed something?

Just as a note: Manually hack twig-cache from:

$this->getAttribute((isset($context["app"]) ? $context["app"] : $this->getContext($context, "app")), "request", array())

to

$this->getAttribute($this->getAttribute((isset($context["app"]) ? $context["app"] : $this->getContext($context, "app")), "request_stack", array()), "getCurrentRequest", array())

would prevent this issue and of course force web-profiler-bundle to v2.6.7 in composer.json, too:

"symfony/web-profiler-bundle": "v2.6.7"
@patrick-fls
Copy link

👍 thanks @DRMONTY, this was driving me mad since everything was fine last night!

fabpot added a commit to symfony/symfony that referenced this issue May 29, 2015
…tes (stof)

This PR was merged into the 2.6 branch.

Discussion
----------

Avoid using the app global variable in the profiler templates

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | small one for people overwriting the WebDebugToolbarListener methods
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | silexphp/Silex-WebProfiler#64
| License       | MIT
| Doc PR        | n/a

#14217 introduced a usage of the ``app`` global variables in profiler templates, while we previously removed all such usages to avoid the dependency on TwigBundle in these templates.
This keeps them usable outside the fullstack framework (for instance in Silex).

I had to do a small BC break to be able to pass the request in the place where we were not yet injecting the Request in the template.

Commits
-------

415c79e Avoid using the app global variable in the profiler templates
@fabpot fabpot closed this as completed May 29, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants