ビット:このような何かを返す必要があります
$appPath = $this->container->getParameter('kernel.root_dir');
$webPath = realpath($appPath . '/../web');
$webPath
を/異なるアプリケーション用のURIパス。
Symfony\Component\HttpFoundation\Request
コンポーネントを使用すると、これを呼び出すことができるさまざまな方法があります。
は、このリンクhttp://dev.col.com/app_dev.php/my-route?bar=1&foo=bar
$r = $this->getRequest();
$r->getClientIp() 127.0.0.1
$r->getScriptName() /app_dev.php
$r->getPathInfo() /my-route
$r->getBasePath() ''
$r->getBaseUrl() /app_dev.php
$r->getScheme() http
$r->getPort() 80
$r->getHttpHost() dev.col.com
$r->getRequestUri() /app_dev.php/my-route?bar=1&foo=bar
$r->getBaseServerUrl() http://dev.col.com
$r->getUri() http://dev.col.com/app_dev.php/my-route?bar=1&foo=bar
$r->getUriForPath("/other-path") http://dev.col.com/app_dev.php/other-path
$r->getQueryString() bar=1&foo=bar
$r->isSecure() false
$r->getHost() dev.col.com
$r->getMethod() GET
$r->isXmlHttpRequest() false
それともあなたが同様に小枝でそれを行うことができます考えてみましょう。たとえば、次のように
<div>
<a href="{{ job.url }}">
<img src="{{ app.request.scheme ~ '://' ~ app.request.host }}{{ asset(job.webPath) }}" alt="{{ job.company }} logo" />
</a>
</div>
<div>
<a href="{{ job.url }}">
<img src="{{ app.baseServerUrl }}{{ asset(job.webPath) }}"alt="{{ job.company }} logo" />
</a>
</div>