PHP Framework --- Symfony 读书笔记1

来源:互联网 发布:淘宝达人认证 编辑:程序博客网 时间:2024/04/20 00:15

Symfony2虽然已经Release了,但还是想从1.14.x版本开始学起。

官方主页:http://www.symfony-project.org/

下载地址:http://www.symfony-project.org/installation/1_4


确认PHP环境,使用Apache服务器。

首先需要通过命令行代码生成文件目录结构。

步骤如下:

1. 在指定路径下新建工程文件夹,例如 sfproject 。

2. 在工程文件夹( sfproject )下新建目录 lib\vendor\

3. 下载并解压 symfony, symfony-1.4.xx.zip.改名symfony后移至 lib\vendor\ 下

4. 使用命令行生成工程文件

    php lib\vendor\symfony\data\bin\symfony generate:project PROJECT_NAME

主要目录如下:

DirectoryDescriptionapps/Hosts all project applicationscache/The files cached by the frameworkconfig/The project configuration filesdata/Data files like initial fixtureslib/The project libraries and classeslog/The framework log filesplugins/The installed pluginstest/The unit and functional test filesweb/The web root directory (see below)

5. 使用命令行生成web前端文件

    php lib\vendor\symfony\data\bin\symfony generate:app frontend

6. 修改config\databases.yml文件中数据库配置信息。

    也可使用命令行: $ php symfony configure:database "mysql:host=localhost;dbname=dbname" root mYsEcret

7. Web Server Configuration修改示例:

# Be sure to only have this line once in your configurationNameVirtualHost 127.0.0.1:8080# This is the configuration for your projectListen 127.0.0.1:8080<VirtualHost 127.0.0.1:8080>  DocumentRoot "/home/sfproject/web"  DirectoryIndex index.php  <Directory "/home/sfproject/web">    AllowOverride All    Allow from All  </Directory>  Alias /sf /home/sfproject/lib/vendor/symfony/data/web/sf  <Directory "/home/sfproject/lib/vendor/symfony/data/web/sf">    AllowOverride All    Allow from All  </Directory></VirtualHost>