# 安裝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.