php集成工具xampp;
一、pear安装symfony
pear添加环境变量;
- Set right include path and to make sure that all pear packages will be installed in the right locations.
- Goto System Properties into the Advanced tab.
- Click on Environment Variables
- Extend the path variable by adding your path to php, mysql and pear:
In my case, as I installed XAMPP to e:\xampp, it was like adding
;e:\xampp\php\PEAR\symfony;e:\xampp\mysql\bin;e:\xampp\php;e:\xampp\php\PEAR
- Open a command line (Start menu, Start Application, Run "cmd"
- Enter your XAMPP directory:
e:
cd xampp
(This can be different for you!)
- Upgrade pear:
pear upgrade pear - Install phing:
pear install -a http://phing.info/pear/phing-current.tgz --alldeps - Install symfony:
- pear channel-discover pear.symfony-project.com
- pear install symfony/symfony
查看版本:
-
symfony -V
在创建项目之前,首先需要搭建symfony发开环境。
二、创建应用
win7 64;xampp安装路径是e:\xampp\htdocs
>md cms
>cd cms
>symfony generate:project cms
>symfony generate:app frontend
>symfony generate:app backend
2. Apache下配置项目(新建虚拟主机)
<VirtualHost *:1300>
DocumentRoot "e:\xampp\htdocs\cms\web"
DirectoryIndex index.php
<Directory "e:\xampp\htdocs\cms\web">
AllowOverride All
Allow from All
</Directory>
Alias /sf e:\xampp\htdocs\data\symfony\web\sf
<Directory "e:\xampp\htdocs\data\symfony\web\sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
注意:
以上配置需要添加在httpd-vhosts.conf文件中,并在httpd.conf中打开对相应端口的监听。
直接使用localhost ;或使用新域名C:\Windows\System32\drivers\etc过修改hosts文件添加相应的域名解析 :127.0.0.1 cms
重启Apache后,通过访问http://cms:1300/ 可以看到symfony工程欢迎页面。
从这里开始,我们可以选择一个顺手的IDE打开工程,以便更好的发开项目。
3. 配置并创建数据库
打开工程下config中的databases.yml文件,修改数据库连接的参数。
# You can find more information about this file on the symfony website:
# http://www.symfony-project.org/reference/1_4/en/07-Databases
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: mysql:host=localhost;dbname=cms
username: admin
password: admin
定义schema ( cms/config/doctrine/schema.yml )