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
主要目錄如下:
| Directory |
Description |
| apps/ |
Hosts all project applications |
| cache/ |
The files cached by the framework |
| config/ |
The project configuration files |
| data/ |
Data files like initial fixtures |
| lib/ |
The project libraries and classes |
| log/ |
The framework log files |
| plugins/ |
The installed plugins |
| test/ |
The unit and functional test files |
| web/ |
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>