Symfony 2 fresh install no url works

2019-07-20 16:14发布

问题:

I have a problem and I know that you will assume that it was covered in many other similar topics. But please bear with me for a moment. I've read other topics about

No route found for GET/

but my problem is different. It works for other programmers when they used url/app_dev.php and was not working only while using url/app.php. For me none of them works.

I am just trying to learn Symfony2 from scratch. All internet resources assume that you had already worked with some other framework that is similar to Symfony and it is not your first so they are covered in jargon and do not explain anything. I just know HTML, CSS, Javascript and PHP, so I want to learn how to use Symfony and this is the first framework I have ever used.

I have only one possible to decode tutorial on symblog.co.uk/

So I follow the steps from tutorial and despite doing all they write there I get different result. At first their homepage on fresh installation looks like that

http://postimg.org/image/4mgq50imn/

While mine looks like that (Left Screen)

http://postimg.org/image/4p6ft0h8r/

And I also get it on any other page with exception of app/example that is blank.

To continue tutorial I need to use application interface from working homepage. And I can not access it. I can obviously edit file with database connection but I want to do stuff according to tutorial because I am new to frameworks.

Can you please help me with that problem? I am guessing this is the problem with routing, but in tutorial they first had their homepage working and then they advise to start creating/rewriting routing.

I probably do not sound like I am a very wise person. But this is the last place I can ask for help on the internet. Everywhere else they just answer my long message like this - "routing" or "hosts" and send me to the Symfony website (despite me saying that this is place where I was and couldn't understand/find answer). So if you think that there is something wrong with me because I started learning Symfony last week and do not understand much, even if I spent many hours searching for answers please ignore this question or answer me like to person that never used frameworks.

Here is my apache httpd.conf:

Alias /bitnami/ "/opt/lampp/apache2/htdocs/"
Alias /bitnami "/opt/lampp/apache2/htdocs"

<Directory "/opt/lampp/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

# /etc/httpd/conf/httpd.conf

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
  ServerName symblog.dev
  DocumentRoot "/opt/lampp/htdocs/symblog.dev/web"
  DirectoryIndex app.php
  <Directory "/opt/lampp/htdocs/symblog.dev/web">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

And I added this to etc/hosts

# /etc/hosts from symfony tutorial
127.0.0.1     symblog.dev

I don't know what to do. I just want to go through this tutorial to have some idea about Symfony...

回答1:

May be I'm posting the wrong answer, but there was a bundle called Acme which consisted of some demo pages, configs before, but it was removed recently. If you look at the files of web folder, there are app.php, app_dev.php, and config.php files, and this config.php file should output this page, not app_dev.php. Try to open it directly, like http://symblog.dev/config.php.

If you want to try if your installation is working or not you can open app/example page, which is shipped by the latest version. It should output this page. You can also look at this this tutorial (written for v2.3) for better understanding how the system works.