To learn symfony, you must first learn how to install symfony. This article talks about how to install the symfony framework under Windows. The installation under Linux is similar.
1. First downloadsymfony from this address:http://symfony.com/legacy, this series of tutorials uses version 1.2 of symfony.
2. Create a project directory under the root directory of your website, such as bolg, then create a lib directory in this directory, create a vendor directory under the lib directory, and unzip the downloaded symfony compressed package. Go to the vendor directory.
3. Open the command line tool, enter the blog directory, enter the following command to create a symfony project
php lib\vendor\symfony\data\bin\symfony generate-project blog
This command creates the following directory structure:
The description of each directory is as follows:
Directory | Description |
---|---|
apps/ | Store all applications of the project |
cache/ | The cache file of the framework |
config/ | Project configuration file |
lib/ | Classes and libraries used in the project |
log/ | Project log file |
plugins/ | Installed plug-ins |
test/ | Unit test and functional test files |
web/ | Website root directory (see below) |
php symfony init-app frontend
另外还在web目录下生成了如下文件:index.php和frontend_dev.php
其中index.php是生产环境的入口文件,frontend_dev.php是测试的入口文件,通过frontend_dev.php访问程序,会在页面上展示一个调试栏,方便我们调试程序。至于为什么index.php不叫frontend.php,那是因为symfony在创建第一个应用程序的时候默认使用index.php作为生产环境入口文件。
5、设置虚拟主机
如果你使用的是apache作为服务器,将如下代码加入到apache的配置文件,再重启apache即可。
Listen 127.0.0.1:8080DocumentRoot "H:/wamp/www/blog/web" DirectoryIndex index.php AllowOverride All Allow from All Alias /sf H:/wamp/www/symfony/data/web/sfAllowOverride All Allow from All
现在打开浏览器,访问http://localhost:8080,可以看到如下页面:
访问http://localhost:8080/frontend_dev.php:
有一些报错信息,是由于php版本原因的报错,暂时不作处理。可以看到测试控制器的右上角多了个调试框。
今天就讲到这里,下一篇将结束symfony的页面创建知识。
The above is the detailed content of Detailed tutorial on symfony installation. For more information, please follow other related articles on the PHP Chinese website!