# 安装Propel
Propel 可以通过clone Propel官方Github 仓库, 或者是通过Github checkout SVN ,或者是依靠"传统"的下载tgz或zip包. 不管通过什么方式,你都可以轻松获取Propel.
* * * * *
## 准备清单
Propel 需要搭配以下环境使用:
* PHP 5.5或者更新, 需要启用DOM (libxml2) 模块
* 一个Propel支持的数据库(MySQL, MS SQL Server, PostgreSQL, SQLite, Oracle)
* 运行Propel也用到了一些Symfony2的组件:
[Config](https://github.com/symfony/Config) : 用于源代码中进行管理和验证配置项.
[Console](https://github.com/symfony/Console) : 用于管理Propel命令生成.
[Yaml](https://github.com/symfony/Yaml)
[Validator](https://github.com/symfony/Validator) : 通过Propel管理数据校验的方式.
[Finder](https://github.com/symfony/Finder) : 在源代码中用于管理文件.
*Tip 小提示*
Propel 使用到 PDO 和 SPL 组件, 它们已经在PHP5中附随并默认启用.
## 安装Propel
### 通过 Composer 安装
我们建议您通过Composer去管理您项目中的依赖, 如果您想通过Compser安装Propel, 仅需在您的项目根目录建立一个新的composer.json文件, 并添加下列内容
~~~
{
"require": {
"propel/propel": "~2.0@dev"
}
}
~~~
接下来您需要通过命令行输入下列命令来下载Compser:
~~~
$ wget http://getcomposer.org/composer.phar
~~~
如果您的电脑上没有wget
~~~
$ curl -s http://getcomposer.org/installer | php
~~~
将Composer安装完成后, 输入下列命令来安装您项目的依赖包:
`$ php composer.phar install`
### 通过 git 安装
只要您想, 您当然也可以通过Git cloning 官方 Github仓库
~~~
$ git clone git://github.com/propelorm/Propel2 vendor/propel
~~~
Propel is well unit-tested so the cloned version should be pretty stable. If you want to update Propel, just go to the repository and pull the remote:
~~~
$ cd myproject/vendor/propel
$ git pull
~~~
### 使用 Tarball 或者 Zipball
再或者,使用tarball 或者 Zipball也是可以的,在unix平台上键入以下命令:
~~~
$ cd myproject/vendor
$ wget http://files.propelorm.org/propel-2.0.0.tar.gz
$ tar zxvf propel-2.0.0.tar.gz
$ mv propel-2.0.0 propel
~~~
Windows平台下, 通过 [files.propelorm.org](http://files.propelorm.org) 地址下载ZIP包, 将其解压后放入 vendor/ 目录, 最后把它的名字改为propel.
* * * * *
### Propel Directory Structure
The root directory of the Propel library includes the following folders:
Folders Explanations
bin Contains three scripts that manage propel command line tool (depending of your operating system)
features Tests written with the Behat framework
resources Contains some files such as the database XSD or DTD
src The Propel source code. Pass over if you just want to use Propel, not to contribute.
tests Propel unit tests. Ignore this if you don’t want to contribute to Propel.
Testing Propel Installation
The Propel generator component bundles a propel sh script (and a propel.bat script for Windows). This script makes it easy to execute build commands. You can test this component is properly installed by calling the propel script from the CLI:
~~~
$ cd myproject
$ vendor/bin/propel
~~~
The command should output the propel version following by a list of the options and the available commands. We will learn to use these commands later.
> Tip
> In order to allow an easier execution of the script, you can also add the propel generator’s bin/ directory to your PATH, or create a symlink. For example:
> $ cd myproject
> $ ln -s vendor/bin/propel propel
> Or simply edit your .bashrc or .zshrc file:
> export PATH=$PATH:/path/to/vendor/bin/
> On Windows you could set the PATH for the opened command with:
> set PATH=%PATH%;C:/path/to/vendor/bin/
> To globally define the PATH adjust it inside the “Environment Variables”, which you can find in your system advanced settings panel.
At this point, Propel should be setup and ready to use. You can follow the steps in the Build Guide to try it out.
Troubleshooting
Getting Help
If you can’t manage to install Propel, don’t hesitate to ask for help. See Support for details on getting help.