dongshuzui0335 2017-07-17 18:42
浏览 97

Symfony 3 - 总是得到404错误

I am a beginner in Symfony 3.

I've installed it and when i go to http://localhost/Symfony/web/app_dev.php the page is displaying then there is a javascript confirm box with the message "An error occured while loading the web debug toolbar (404:Not Found). Do you want to open the profiler?"

Even if i go to http://localhost/Symfony/web/app_dev.php/test i have a 404 error page, but it is not the Symfony 404 page.

I am on Ubuntu and Nginx.

I have tried differents things but nothing were correct for me.

Could you give me a hand on that so I don't have this confirm box and can go to others pages ?

Thanks.

UPDATE: In the var/logs/dev.log i have this message :

[2017-07-18 11:00:39] request.INFO: Matched route "homepage". {"route":"homepage","route_parameters":{"_controller":"AppBundle\\Controller\\DefaultController::indexAction","_route":"homepage"},"request_uri":"http://localhost/Symfony/web/app_dev.php/","method":"GET"} []
[2017-07-18 11:00:39] security.INFO: Populated the TokenStorage with an anonymous Token. [] []

Edit :

I restart the install with the version 3.3.5

I did these line and it worked a little bit better :

sudo mkdir -p /usr/local/bin
sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

I had to change the composer.json too with these lines :

"autoload": {
        "psr-4": {
            "": "src/"
        },

Here my nginx config :

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/html;

    index index.html index.htm index.nginx-debian.html;

    server_name localhost;

    location / {
                try_files $uri $uri/ /index.php?$args /app.php$is_args$args;
    }

# start symfony
location ~ ^/(app_dev|config)\.php(/|$) {
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
    }
# end symfony

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9000;
    }
}

But I still have the 404 error page for any pages, even for a bundle that I have generated.

Any ideas ?

  • 写回答

2条回答 默认 最新

  • duanlan2003 2017-07-18 12:52
    关注

    First of all, point your site's root to the web folder. Not any of its parents. And check again.

    For the debug toolbar, check your security.yml There should be a firewall dev that closes security for js, images etc

    Something like

    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern: ^/(_(profiler|wdt)|css|images|js)/
            security: false
    
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!