[英]Symfony2 - Twig updates are not rendering
我是Symfony2的初學者。 我已經創建了第一個模板,並且可以通過URL http://localhost/mylibrary-web/web/app_dev.php/hello/Test訪問它。
這是我的src/MyLibrary/LibraryBundle/Resources/views/Default/index.html.twig
文件的內容:
Hello {{ name }}!
我沒有工具欄 (因為我沒有</body>
元素,但是如果我使用以下命令更新index.html.twig
文件:
<html>
<body>
Hi {{ name }}!
</body>
</html>
沒有什么變化。 不考慮這些修改。 當我調用URL http://localhost/mylibrary-web/web/app_dev.php/hello/Test時,舊內容仍然顯示。
我試圖使用命令行php app\\console cache:clear
。 我還嘗試通過刪除app\\cache
目錄來硬刪除app\\cache
。 最后,我嘗試config_dev.yml
下行添加到config_dev.yml
文件:
twig:
cache: false
不幸的是,沒有任何變化,我仍然顯示舊內容。
我是否缺少更新樹枝文件的內容?
預先感謝您的幫助 !
編輯:
這是src/MyLibrary\\LibraryBundle\\Controller\\DefaultController.php
文件的代碼:
<?php
namespace MyLibrary\LibraryBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class DefaultController extends Controller
{
public function indexAction($name)
{
return $this->render('MyLibraryLibraryBundle:Default:index.html.twig', array('name' => $name));
}
}
以及命令行php app\\console route:debug
:
[router] Current routes
Name Method Scheme Host Path
_wdt ANY ANY ANY /_wdt/{token}
_profiler_home ANY ANY ANY /_profiler/
_profiler_search ANY ANY ANY /_profiler/search
_profiler_search_bar ANY ANY ANY /_profiler/search_bar
_profiler_purge ANY ANY ANY /_profiler/purge
_profiler_info ANY ANY ANY /_profiler/info/{about}
_profiler_phpinfo ANY ANY ANY /_profiler/phpinfo
_profiler_search_results ANY ANY ANY /_profiler/{token}/search/results
_profiler ANY ANY ANY /_profiler/{token}
_profiler_router ANY ANY ANY /_profiler/{token}/router
_profiler_exception ANY ANY ANY /_profiler/{token}/exception
_profiler_exception_css ANY ANY ANY /_profiler/{token}/exception.css
_configurator_home ANY ANY ANY /_configurator/
_configurator_step ANY ANY ANY /_configurator/step/{index}
_configurator_final ANY ANY ANY /_configurator/final
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
my_library_library_homepage ANY ANY ANY /hello/{name}
homepage ANY ANY ANY /app/example
編輯2:
這是my_library_library_homepage路由的定義:
my_library_library_homepage:
path: /hello/{name}
defaults: { _controller: MyLibraryLibraryBundle:Default:index }
這就是我grep Hello {{ name }}!
:
可能很奇怪,但是...重新啟動wamp服務之后,一切似乎都可以正常工作...
首先,檢查您是否具有寫入文件夾緩存的權限:
app/cache/dev/
刪除那里的所有文件並運行:
php app/console cache:clear --env=dev
php app/console cache:warmup --env=dev
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.