PHPackages                             dtforce/slim-hook - 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. [API Development](/categories/api)
4. /
5. dtforce/slim-hook

AbandonedArchivedLibrary[API Development](/categories/api)

dtforce/slim-hook
=================

A Gitlab webhook using Slim Framework

v1.0.0(9y ago)3261MITPHPPHP &gt;=5.5.0

Since Aug 20Pushed 9y ago2 watchersCompare

[ Source](https://github.com/DTForce/slim-hook)[ Packagist](https://packagist.org/packages/dtforce/slim-hook)[ Docs](http://github.com/dtforce/slim-hook)[ RSS](/packages/dtforce-slim-hook/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

[![Build Status](https://camo.githubusercontent.com/18ec233f0f54025535d6e28127abaf1418f493f251c98888375404ec0b1e7c2a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4454466f7263652f736c696d2d686f6f6b2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DTForce/slim-hook/build-status/master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/2b228b3ff6dc4075faf945d73fbd0e7daa5156d5b524de2c380f667b4a4e2e3b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4454466f7263652f736c696d2d686f6f6b2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DTForce/slim-hook/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/ec88a5785340a305dee6ea14f06a6ea42307e85d24e6da2bbac66a5d4d7ab938/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4454466f7263652f736c696d2d686f6f6b2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/DTForce/slim-hook/?branch=master)

Gitlab webhook in PHP
=====================

[](#gitlab-webhook-in-php)

This is a very simple webhook for gitlab, allowing to start bash scripts as a reaction to BUILD, PUSTH and TAG events.

Installation
------------

[](#installation)

Install with composer:

```
composer create-project dtforce/slim-hook

```

Or by cloning this repo.

Configuration
-------------

[](#configuration)

Create a file `local.yaml` in the `config` folder containing something like this:

```
settings:
  secret: 3219874514564 - this should match your webhook secret token
scripts:
  gitlab-org/gitlab-test: - name of the project
    deploy: - what event do we react to
      staging: bash /path/to/app/test.bash deploy - on deploy, what enviroment do we consider
    push:
      refs/heads/master: - on push, what branch do we consider
        cwd: /path/to/app - optional you can set working directory
        - bash /path/to/app/test.bash push - this is going to be executed throug shell_exec
    tag:
        - bash /path/to/app - on tag no subcategories
        - bash do-smothin-else - you can execute multiple commands with one hook
  gitlab-org/gitlab-something-else: - more projects
```

Variables
---------

[](#variables)

When is your script being executed, there are few variables, given to the environment.

These are examples, it should be quite clear:

### Deploy

[](#deploy)

```
[
    'HOOK_PROJECT_PATH' => 'gitlab-org/gitlab-test',
    'HOOK_BUILD_ID' => 379,
    'HOOK_BUILD_REF' => 'bcbb5ec396a2c0f828686f14fac9b80b780504f2',
    'HOOK_ENV_NAME' => 'staging'
]
```

### Push

[](#push)

```
[
    'HOOK_PROJECT_PATH' => 'gitlab-org/gitlab-test',
    'HOOK_REF' => 'refs/heads/master',
    'HOOK_BRANCH' => 'master',
    'HOOK_BUILD_REF' => 'da1560886d4f094c3e6c9ef40349f7d38b5d27d7'
]
```

### Tag

[](#tag)

```
[
    'HOOK_PROJECT_PATH' => 'jsmith/example',
    'HOOK_REF' => 'refs/tags/v1.0.0',
    'HOOK_TAG' => 'v1.0.0',
    'HOOK_BUILD_REF' => '82b3d5ae55f7080f1e6022629cdb57bfae7cccc7'
]
```

Launching
---------

[](#launching)

You can configure Apache in the usual way, or you can launch using PHP embedded server like this:

```
/usr/bin/php7.0 -S localhost:8080 -t /path/to/app/slim-hook/public

```

BashREST
--------

[](#bashrest)

For convenience this application can also serve simple REST requests. This can be handy, when you want a result of the script executed on the target platform when deploying in gitlab CI. By making request to this server in the following form:

`POST to /groupName/projectName/action`

you will launch a script described in the config like this:

```
bashREST:
  groupName/projectName:
    action: launch some bash command here
    action2:
      cwd: dir
      0: test1
      1: test2
```

If you sent some data (in the form of JSON) in the POST body, the script will receive them in its enviroment variables in a flattened form.

Example:

```
{
    "test" : "asd",
    "nested" : {
        "a" : "b",
        "asd" : "c"
    },
    "array" : ["asd", "zxc", "xcvxcv"]
}
```

sent as POST to `/bash-rest/test-app/my-action`

Will result in these environment variables set:

```
HOOK_PROJECT_PATH=bash-rest/test-app
HOOK_ACTION=my-action
HOOK_test=asd
HOOK_nested_a=b
HOOK_nested_asc=c
HOOK_array_0=asd
HOOK_array_1=zxc
HOOK_array_2=xcvxcv
```

If you set-up your secret in the config script, request to the **BashREST**server will need to authorize themselves with this secret. Secret is stored in header field `X-Secret`. Notice it is different to the one used by Gitlab Webhooks.

### Example of a BashREST call

[](#example-of-a-bashrest-call)

Suppose config:

```
bashREST:
  groupName/projectName:
    deploy: echo Application $HOOK_PROJECT_PATH action $HOOK_ACTION called with ENV set to $HOOK_ENV
```

and assume, `shell_exec` launches `sh` or `bash`, then call the action like this:

```
curl -X POST http://localhost:4000/groupName/projectName/deploy -H \
    "X-Secret: $BASH_REST_SECRET" -H 'Content-Type: application/json' -d '{"ENV":"production"}'
```

The response will be returned as `application/text` containing result(written to `stdout`) of the executed command:

```
Application groupName/projectName action deploy called with ENV set to production
```

The idea is to have something like RPC for `bash` over HTTP protocol.

That's all
----------

[](#thats-all)

Hope you like it!

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

3597d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1552179?v=4)[Jan Mareš](/maintainers/maresja1)[@maresja1](https://github.com/maresja1)

---

Top Contributors

[![maresja1](https://avatars.githubusercontent.com/u/1552179?v=4)](https://github.com/maresja1 "maresja1 (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dtforce-slim-hook/health.svg)

```
[![Health](https://phpackages.com/badges/dtforce-slim-hook/health.svg)](https://phpackages.com/packages/dtforce-slim-hook)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[showdoc/showdoc

ShowDoc is a tool greatly applicable for an IT team to share documents online

12.8k7.1k](/packages/showdoc-showdoc)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k406.5k25](/packages/team-reflex-discord-php)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[partitech/php-mistral

Connect to Mistral | Anthropic | Xai | Hugging Face | LamaC++ | Vllm | Ollama

2731.8k1](/packages/partitech-php-mistral)

PHPackages © 2026

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