我不完全确定发生了什么,因为这是我第一次遇到这种问题,但由于某种原因,我的Symfony2项目中的一个特定页面在app.php上有一个重定向循环,但在app_dev上.php,没关系。
页面名为/ files,此页面的路由如下:
app_files_table:
path: /files
defaults: { _controller: AppBundle:File:list }
此页面的控制器方法非常简单:
public function listAction()
{
$em = $this->getDoctrine()->getManager();
$documents_repo = $em->getRepository('AppBundle:Documents');
$documents = $documents_repo->findAll();
return $this->render('AppBundle:tables:files.html.twig', array(
'files' => $documents
));
}
twig模板只是一个标准布局,它匹配我所有其他页面(扩展我的基本文件,即标题),主体中包含以下代码:
{% if files is not empty %}
{% for file in files %}
<tr>
<th scope="row">{{ file.id }}</th>
<td>{{ file.name }}</td>
<td>{{ file.displayName }}</td>
<td>{{ file.product.model }}</td>
<td class="text-center">
<a class="btn btn-primary" href="{{ file_path }}/{{- file.name -}}" target="_blank" download><i class="fa fa-download"> </i></a>
<a class="btn btn-danger file-delete" data-confirm-title="Are you sure?" data-confirm-message="You will not be able to undo this action." href="javascript:deleteFile({{ file.id }});" id="delete_file_{{ file.id }}" data-toggle="tooltip" title="Remove File"><i class="fa fa-remove"> </i></a>
</td>
</tr>
{% endfor %}
{% else %}
<tr>
<td colspan="5">There are no files in the database</td>
</tr>
{% endif %}
我没有编辑app.php,app_dev.php和.htaccess文件 - 它们与安装框架时一样。我还清除了两次缓存,包括手动删除所有缓存文件 - 但仍然会出现重定向问题。
这是其他人遇到并设法解决的问题吗?因为我很困惑为什么它应该在这个页面上发生 - 事实上,我甚至尝试在模板渲染之前在控制器中放置一个die()语句,但是同样的事情发生了所以它必须与路由一起?
任何帮助表示感谢。
谢谢
编辑 - 调试结果:路由器
_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
_twig_error_test ANY ANY ANY /_error/{code}.{_format}
app_dashboard ANY ANY ANY /
app_user_dashboard ANY ANY ANY /user-dashboard
fos_user_security_login ANY ANY ANY /login
fos_user_security_check ANY ANY ANY /login_check
app_customers_table ANY ANY ANY /customers
app_orders_table ANY ANY ANY /orders
app_projects_table ANY ANY ANY /projects
app_products_table ANY ANY ANY /products
app_files_table ANY ANY ANY /documents
app_users_table ANY ANY ANY /users
app_categories_table ANY ANY ANY /categories
app_customer_view ANY ANY ANY /customer/{id}/{orderYear}
app_order_view ANY ANY ANY /order/{id}
app_project_view ANY ANY ANY /project/{id}
app_user_view ANY ANY ANY /user/{id}
app_customer_add ANY ANY ANY /customer/add
app_address_add ANY ANY ANY /address/add/{id}
app_order_add ANY ANY ANY /order/add
app_user_add ANY ANY ANY /user/new
app_stage_add ANY ANY ANY /stage/new
app_category_add ANY ANY ANY /category/new
app_document_add ANY ANY ANY /document/new/
fos_user_registration_register ANY ANY ANY /new-user
fos_user_security_logout ANY ANY ANY /logout
fos_user_registration_check_email ANY ANY ANY /check-email
fos_user_registration_confirm ANY ANY ANY /confirm/{token}
fos_user_registration_confirmed ANY ANY ANY /confirmed
fos_user_profile_show ANY ANY ANY /profile
fos_user_profile_edit GET|POST ANY ANY /profile-edit
app_missing_orders_table ANY ANY ANY /missing-orders
app_delete_item ANY ANY ANY /delete/{type}/{id}
app_calendar ANY ANY ANY /calendar
app_ajax_call ANY ANY ANY /ajax-call/{action}/{data}
app_customer_search ANY ANY ANY /customer-search
app_customer_get ANY ANY ANY /customer-get
app_product_search ANY ANY ANY /product-search
app_product_search_id ANY ANY ANY /product-search-by-id
app_product_get ANY ANY ANY /product-get
app_add_order ANY ANY ANY /add-order
app_print_job_label ANY ANY ANY /print-job-label/{id}
app_claim_task ANY ANY ANY /claim-task/{id}
app_complete_task ANY ANY ANY /complete-task/{id}
app_stages_edit ANY ANY ANY /edit-stages
app_category_edit ANY ANY ANY /edit-category/{id}
app_run_cron_task ANY ANY ANY /cron-generate-projects
remove_trailing_slash GET ANY ANY /{url}
fullcalendar_loader ANY ANY ANY /fc-load-events
fos_js_routing_js ANY ANY ANY /js/routing.{_format}
答案 0 :(得分:0)
我建议你重建你的bootstrap缓存,你可以通过composer脚本来完成它,因为你可以做它的生产:
composer install -o --no-dev
或者只是
composer run-script post-install-cmd
您也可以考虑删除整个缓存目录并删除app/bootstrap.php.cache
文件。
如果它不起作用,我们将需要更多信息,如配置文件,环境,日志等。