Detailed tutorial on symfony installation

巴扎黑
Release: 2023-03-14 19:54:01
Original
2575 people have browsed it

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 download symfony from this address: http://symfony.coDetailed tutorial on symfony installationm/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
Copy after login

This command creates the following directory structure:


The description of each directory is as follows:

DirectoryDescription
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)
4、目前这个项目还没法使用,因为我们至少需要创建一个应用程序,在当前目录在创建一个前台(frontend)应用程序
php symfony init-app frontend
Copy after login
这个命令在apps目录下生成了如下目录:


另外还在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:8080

<VirtualHost 127.0.0.1:8080>
  DocumentRoot "H:/wamp/www/blog/web"
  DirectoryIndex index.php
  <Directory "H:/wamp/www/blog/web">
    AllowOverride All
    Allow from All
  </Directory>

  Alias /sf H:/wamp/www/symfony/data/web/sf
  <Directory "H:/wamp/www/symfony/data/web/sf">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>
Copy after login


注:如上写法只针对windows。注意将以上目录转换成你的开发环境的对应目录。

现在打开浏览器,访问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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!