git-deploy-php allows quick and easy deployments of Git repositories to FTP servers.
It was created to simplify the process of deploying projects to shared hosting environments where shell access is not available, and to save bandwidth, by only uploading the files that have changed.
Using git-deploy-php could not be easier.
- Drop
git-deploy
into your project. - Create the
deploy.ini
file (see below). - Execute
php git-deploy
.
And there you go. It's that simple.
In the root directory of your source code, create a deploy.ini
file.
Note: deploy.ini
is the default file's name. You can name it staging.ini
, for example, and execute php git-deploy staging
. That serves as an easy way to separate the deployment to staging and production servers.
; This is a sample deploy.ini file.
[example]
skip = false
user = example
pass = password
host = example.com
port = 21
path = /path/to/installation
passive = true
; If that seemed too long for you, you can specify servers like this:
[ftp://example:password@example.com:21/path/to/installation]
The first time it's executed, git-deploy will assume that your deployment server is empty, and will upload all the files in the git repository. If you've already deployed your project's files previously, you have to create a REVISION file on your deployment server, containing the hash of the revision it's currently in.
To get the hash of the current revision, you can use:
git rev-parse HEAD
Sometimes, you may just want to see what files are to be uploaded to the FTP server, and which ones are to be deleted. In this case, you can use -l
(lowercase L):
php git-deploy [your_ini_file_name] -l
If you use deploy.ini (i.e., if you didn't give the .ini file a custom name), then you can simply use:
php git-deploy -l
Pretty simple, huh?
git-deploy stores file called REVISION on your server inside the root path to your application. This file stores the current revision of your application residing on your server.
When you run a git deploy, git-deploy downloads the REVISION file, and checks to see what files are different between revisions and either upload the changed files or deletes them from the server.
If you've got any suggestions, questions, or anything you don't like about git-deploy-php, create an issue. I'd really appreciate your feedback. Feel free to fork this project, if you want to contribute to it.