PHPackages                             webforward/gitdeploy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. webforward/gitdeploy

ActiveLibrary

webforward/gitdeploy
====================

Easy to use automatic git deployment for PHP projects with composer and npm support

125PHP

Since Dec 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/webforward/gitdeploy)[ Packagist](https://packagist.org/packages/webforward/gitdeploy)[ RSS](/packages/webforward-gitdeploy/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

GitDeploy
=========

[](#gitdeploy)

*Easy to use automatic git deployment for PHP projects with composer and npm support.*

Requirements
------------

[](#requirements)

- PHP 7.0 or above with `proc_open` and `shell_exec` functions enabled.
- `git` and `rsync` are required on the server that's running the script (*server machine*).
    - Optionally, `tar` is required for backup functionality (`backup_dir` option).
    - Optionally, `composer` is required for composer functionality (`use_composer`option).
    - Optionally, `npm` is required for composer functionality (`use_npm`option).
- The system user running PHP (e.g. `www-data`) needs to have the necessary access permissions for the `temp_dir` and `target_dir` locations on the *server machine*.
- If the Git repository you wish to deploy is private, the system user running PHP also needs to have the right SSH keys installed to access the remote repository. See GitHub or BitBucket for examples.

Usage - In your own project though composer
-------------------------------------------

[](#usage---in-your-own-project-though-composer)

1. Start by running the command `composer require webforward/gitdeploy:dev-master` .
2. Use the following code in your project and configure options:

```
use GitDeploy\GitDeploy; // PSR-4 - This line must be at the top of a script, not inside a function
$gd = new GitDeploy();
$gd->remote_repository = 'https://github.com/williammalone/Simple-HTML5-Drawing-App.git';
$gd->target_dir = '/home/user/public_html';
// Your configurable options here, see deploy.php
$gd->deploy();
```

3. Setup a check/method in which the above code is not publicly accessible by anyone, the code should be placed behind an admin php session, or the requirement to enter a secret key or password to run the deploy() function. Check `deploy.php`for an easy method of how this can be implemented.
4. Make sure these files also exist within your git repository else (depending on your configured options) they could be removed on the next deployment.
5. Test the deployment by visiting the script url in your browser.
6. Once happy, follow the steps of setting up a hook. See GitHub, BitBucket or Generic Git for examples.

Usage - Standalone
------------------

[](#usage---standalone)

1. Download a copy of this repository into a directory within your website, for example /deploy.
2. Edit `deploy.php` or make your own php file and use the following code with configure options:

```
use GitDeploy\GitDeploy; // This line must be at the top of a script, not inside a function
require 'path/to/src/GitDeploy.php';
$gd = new GitDeploy();
$gd->remote_repository = 'https://github.com/williammalone/Simple-HTML5-Drawing-App.git';
$gd->target_dir = '/home/user/public_html';
// Your configurable options here, see deploy.php
$gd->deploy();
```

3. Setup a check/method in which the above code is not publicly accessible by anyone, you can use the example already written in `deploy.php`. For security reasons, your script should require the input of a secret key or password to run the deploy() function.
4. Make sure these files also exist within your git repository else (depending on your configured options) they could be removed on the next deployment.
5. Test the deployment by visiting the script url in your browser.
6. Once happy, follow the steps of setting up a hook. See GitHub, BitBucket or Generic Git for examples.

### GitHub

[](#github)

1. *(This step is only needed for private repositories)* Go to `https://github.com/USERNAME/REPOSITORY/settings/keys` and add your server SSH key.
2. Go to `https://github.com/USERNAME/REPOSITORY/settings/hooks`.
3. Click **Add webhook** in the **Webhooks** panel.
4. Enter the **URL** for your deployment script e.g. `https://domain.com/deploy.php?secret=changeme`.
5. *Optional* Choose which events should trigger the deployment.
6. Make sure that the **Active** checkbox is checked.
7. Click **Add webhook**.

### Bitbucket

[](#bitbucket)

1. *(This step is only needed for private repositories)* Go to `https://bitbucket.org/USERNAME/REPOSITORY/admin/deploy-keys` and add your server SSH key.
2. Go to `https://bitbucket.org/USERNAME/REPOSITORY/admin/services`.
3. Add **POST** service.
4. Enter the URL to your deployment script e.g. `https://domain.com/deploy.php?secret=changeme`.
5. Click **Save**.

### Generic Git

[](#generic-git)

1. Configure the SSH keys.
2. Add an executable `.git/hooks/post_receive` script that calls the script e.g.

```
#!/bin/sh
wget -q -O /dev/null https://domain.com/deploy.php?sat=changeme
```

You're Done!
------------

[](#youre-done)

Next time you push the code to the repository that has a hook enabled, it's going to trigger the `deploy.php` script which is going to pull the changes and update the code on the *server machine*.

For more info, read the source of `deploy.php` and `src/GitDeploy.php`.

---

If you find this script useful, consider donating to PayPal `richard@webfwd.co.uk`.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9421721?v=4)[Webforward](/maintainers/webforward)[@webforward](https://github.com/webforward)

---

Top Contributors

[![mrl22](https://avatars.githubusercontent.com/u/5681606?v=4)](https://github.com/mrl22 "mrl22 (25 commits)")

### Embed Badge

![Health badge](/badges/webforward-gitdeploy/health.svg)

```
[![Health](https://phpackages.com/badges/webforward-gitdeploy/health.svg)](https://phpackages.com/packages/webforward-gitdeploy)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
