简体   繁体   English

Symfony2新项目不加载资源

[英]Symfony2 new project does not load resources

I'm new to Symfony2 and am trying to follow a tutorial to create a simple project. 我是Symfony2新手,我正在尝试按照教程创建一个简单的项目。 I downloaded Symfony and opened web/config.php . 我下载了Symfony并打开了web/config.php I can see the content of the page but none of the resources (css and images) loaded. 我可以看到页面的内容,但没有加载任何资源(css和图像)。 I'm very new to symfony and searched for a long time but can't find the solution. 我是symfony的新手并且搜索了很长时间但找不到解决方案。 Can anyone help me with it? 任何人都可以帮助我吗?

Here's a screen shot of my config.php and the config.php from the tutorial: 这是我的config.php和教程中的config.php的屏幕截图: 在此输入图像描述

I also noticed that when I click the three links on the page the link doesn't take me to its proper target. 我还注意到,当我点击页面上的三个链接时,链接不会将我带到正确的目标。 For example, it takes me to http://localhost/web/config.php/app_dev.php/_configurator/ when the proper link should have been http://localhost/web/app_dev.php/_configurator/ . 例如,它带我去http://localhost/web/config.php/app_dev.php/_configurator/当适当的链接应该是http://localhost/web/app_dev.php/_configurator/ Notice that what it does is that it didn't remove the config.php from the url. 请注意,它的作用是它没有从url中删除config.php Given the infamous fact that php doesn't handle relative directive intuitively my guess is that this is the root of the problem. 鉴于一个臭名昭着的事实,即php没有直观地处理相对指令,我的猜测是这是问题的根源。 However, I'm really new to symfony and don't know how to fix this. 但是,我是symfony的新手,不知道如何解决这个问题。

Thanks 谢谢


Edit: I'm using apache2.4 on Windows 编辑:我在Windows上使用apache2.4

It just seems like you haven't correctly installed the static assets. 您似乎没有正确安装静态资产。

Try the following command on your shell: 在shell上尝试以下命令:

cd /path/to/project php app/console assets:install web

Alternatively, if you're using a filesystem that supports symbolic links (#nowindows) 或者,如果您使用的是支持符号链接的文件系统(#nowindows)

php app/console assets:install web --symlink

then refresh the config page - that should do it. 然后刷新配置页面 - 应该这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM