[英]Symfony2 project - app_dev.php works but app.php has redirect loop on just specific page
I'm not entirely sure what is happening as it's the first time I've encountered this kind of problem, but for some reason, one particular page in my Symfony2 project has a redirect loop on app.php but when on app_dev.php, it's fine. 我不是很确定发生什么情况,因为这是我第一次遇到这种问题,但是由于某种原因,我的Symfony2项目中的特定页面在app.php上有一个重定向循环,但是在app_dev.php上,没关系。
The page is called /files and the routing for this page is as follows: 该页面称为/ files,此页面的路由如下:
app_files_table:
path: /files
defaults: { _controller: AppBundle:File:list }
The controller method for this page is pretty simple: 此页面的控制器方法非常简单:
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
));
}
The twig template is just a standard layout which matches all my other pages (extending my base file which is the header) with the following code in the main body: 树枝模板只是一个标准布局,它与主体的以下其他代码匹配我所有其他页面(扩展了我的基本文件,即标头):
{% 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 %}
I have not edited the app.php, app_dev.php nor the .htaccess files - they are as they were when the framework was installed. 我尚未编辑app.php,app_dev.php或.htaccess文件-它们与安装框架时一样。 I have also cleared the cache twice including removing all cache files manually - yet the redirect problem still occurs. 我还两次清除了缓存,包括手动删除了所有缓存文件-但是仍然出现重定向问题。
Is this something that others have encountered and managed to solve? 这是别人遇到并设法解决的吗? Because I am confused as to why it should be happening on this page - in fact, I even tried putting a die() statement in the controller BEFORE the template is rendered, yet the same thing happens so it must be to do with the routing? 因为我对为什么它应该在此页面上发生感到困惑-实际上,我什至尝试在呈现模板之前在控制器中放置die()语句,但同样的事情发生了,因此必须与路由有关?
Any help appreciated. 任何帮助赞赏。
Thank you 谢谢
EDIT - result of debug:router 编辑-debug:router的结果
_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}
I recommend you to rebuild your bootstrap cache, you can do it via composer scripts, since its production you could do: 我建议您重建引导缓存,您可以通过composer脚本来完成,因为它可以生产:
composer install -o --no-dev
Or simply 或者干脆
composer run-script post-install-cmd
You may also consider to remove the entire cache directory and delete the app/bootstrap.php.cache
file. 您也可以考虑删除整个缓存目录并删除app/bootstrap.php.cache
文件。
If it doesn't work we will need more information, like config files, environments, logs, etc. 如果它不起作用,我们将需要更多信息,例如配置文件,环境,日志等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.