Skip to content

Commit

Permalink
New rebuild.php script, disabled by default, which can be called fr…
Browse files Browse the repository at this point in the history
…om Git hooks
  • Loading branch information
partageit committed Jun 1, 2015
1 parent fa22692 commit 99bf52e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Private packages bootstrap changelog

## Private packages bootstrap 1.0.2

- New `rebuild.php` script, disabled by default, which can be called from Git hooks

## Private packages bootstrap 1.0.1

- `bootstrap.php` fixed... again. Except the remaining empty `private-packages-bootstrap` folder.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

Private packages Bootstrap bootstraps local Packagist-like, using Satis to provide local repositories.

It provides:

- sample files, easy to update and to version
- simple command to regenerate the Satis repository (`composer build`)
- a rebuild script, to add to your Git hook, in order to automatically regenerate the Satis repository

## Bootstrap the project

Expand All @@ -21,6 +26,10 @@ Edit `repositories.json` and change `name` and `homepage` values.

Take a look at [the boostrap readme file](skel/README.md).

## Customization

Once installed, you are free to change the `composer.json` and `rebuild.php`, for example to change the `web` folder path, or the way to rebuild the Satis repository.

## Requirements

- PHP 5.3+
Expand Down
33 changes: 30 additions & 3 deletions skel/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Private packages bootstrap
# Private packages

## Overview

Private packages is a local Packagist bootstrap, using Satis to provide local repositories.
Provide local repositories using Satis.

## Installation

Expand All @@ -18,7 +18,7 @@ And build the packages list:

## Access

The packages list/documentation can be accessed via `http://<host>/private-packages/web/`.
The packages list can be accessed via `http://<host>/private-packages/web/`.

## Usage

Expand Down Expand Up @@ -47,6 +47,33 @@ Version this repository when required.

The packages list should be re-built when a repository is updated, i.e. when new tags are created.

### Automatic build

If your Web server is able to interpret PHP scripts, you can enable the rebuild function:

composer enable-rebuild-hook

This command-line copies the `rebuild.php` file in the `web` folder, and makes it available at this address: `http://<host>/private-packages/web/rebuild.php`.

You can access it manually, or start it from the Git `post-receive` hook, for example:

```php
#!/usr/bin/env php

<?php
$rebuildResult = file_get_contents("http://uri/private-packages/rebuild.php");

$rebuildResult = explode("\n", $rebuildResult);

if ($rebuildResult[0] === "success") {
echo "Private packages rebuilt!";
} else {
echo "Private packages rebuild failed";
}

echo "\n";
```

## References

The Satis documentation: https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md
4 changes: 3 additions & 1 deletion skel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"composer/satis": "dev-master"
},
"scripts": {
"build": "\"./vendor/bin/satis\" build repositories.json web"
"build": "\"./vendor/bin/satis\" build repositories.json web",
"enable-rebuild-hook": "cp -f rebuild.php web/rebuild.php",
"disable-rebuild-hook": "rm -f web/rebuild.php"
}
}
11 changes: 11 additions & 0 deletions skel/rebuild.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
exec("composer build --working-dir=../", $output, $status);
if ($status === 0) {
echo "success";
} else {
echo "failed";
}

// Uncomment to display details:
// echo "\n<pre>"; print_r($output); echo "</pre>\n";
?>

0 comments on commit 99bf52e

Please sign in to comment.