PHPackages                             phpguard/phpguard - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. phpguard/phpguard

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

phpguard/phpguard
=================

Simple tool to monitor file changes, and run test automatically.

62532PHP

Since Jun 5Pushed 11y ago3 watchersCompare

[ Source](https://github.com/phpguard/phpguard)[ Packagist](https://packagist.org/packages/phpguard/phpguard)[ RSS](/packages/phpguard-phpguard/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependenciesVersions (1)Used By (0)

phpguard
========

[](#phpguard)

Simple tool to monitor file changes, and execute command automatically.

[![License](https://camo.githubusercontent.com/2fefd7db0389e326604a24d1b3a9e6d7ca473c3193d59d18062dc73b740ee0ea/68747470733a2f2f706f7365722e707567782e6f72672f70687067756172642f70687067756172642f6c6963656e73652e706e67)](https://packagist.org/packages/phpguard/phpguard)[![Latest Stable Version](https://camo.githubusercontent.com/4d8c55cce8e62c1429199cb783b6b3b0b5a69041f463203a6c128ac5da809dbe/68747470733a2f2f706f7365722e707567782e6f72672f70687067756172642f70687067756172642f762f737461626c652e706e67)](https://packagist.org/packages/phpguard/phpguard)[![HHVM Status](https://camo.githubusercontent.com/8b5b8e9d10f9fce7149d95e6faa3b8f3295ebf2567337e3fb4552d0dc2d7ce27/687474703a2f2f6868766d2e683463632e64652f62616467652f70687067756172642f70687067756172642e706e67)](http://hhvm.h4cc.de/package/phpguard/phpguard)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/798d5fc2b38543ca29fb52c61d75e0b30add1e8578d0b61011e23a15b6ef7243/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f70687067756172642f70687067756172642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phpguard/phpguard/?branch=master)[![Master Build Status](https://camo.githubusercontent.com/f2c7fba5e798f4baaa7c65d4a31ff01d61b0d129155e2e388e6ed10f0e50fb3a/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f70687067756172642f70687067756172642e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/phpguard/phpguard)[![Coverage Status](https://camo.githubusercontent.com/b399f62506a54b40bcb69e92563bcec73cd1c69365c4c55f493aa474930449e5/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f70687067756172642f70687067756172642f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/phpguard/phpguard?branch=master)

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

[](#installation)

Using composer:

```
$ cd /paths/to/project
$ composer require --dev "phpguard/phpguard 0.1.*@dev"
```

PHP Extension
-------------

[](#php-extension)

At least for now `phpguard\listen` provide inotify support, so if you using linux you can run `phpguard` faster by installing `inotify` extension:

```
$ sudo pecl install inotify
```

And add this line to your `php.ini` file:

```
extension=inotify.so

```

Install Plugin
--------------

[](#install-plugin)

By this time only 3 plugin provided by phpguard:

- Behat Plugin:
- PhpSpec Plugin:
- PHPUnit Plugin:

To learn more about this plugin, please go to the plugin documentation in the related link above. You can install this plugin by using this command:

```
$ cd /path/to/project
$ composer install phpguard/plugin-behat
$ composer install phpguard/plugin-phpspec
$ composer install phpguard/plugin-phpunit
```

Running phpguard
----------------

[](#running-phpguard)

You have to create `phpguard.yml` configuration file first, in order to run `phpguard`. Please take a look `configuration` section below. To start phpguard just type:

```
$ cd /path/to/project
$ ./vendor/bin/phpguard
```

`phpguard` now will start to monitor and run command on file system events. To run all command anytime just press `enter`.

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

[](#configuration)

### PHP Code Coverage options

[](#php-code-coverage-options)

`phpguard` provide coverage feature for cross testing tools. When enabled every test like `phpspec`, `behat`and `phpunit` will be use the same code coverage collector. Available options for coverage:

```
phpguard:
    coverage:
        whitelist:
            - src
        blacklist:
            - spec
            - tests
            - vendor
        show_uncovered_files:   false
        show_only_summary:      false
        output.html:            build/coverage
        output.text:            true
        output.clover:          build/logs/clover.xml
```

You can collect code coverage by using command `./vendor/bin/phpguard all --coverage`

### Ignored directories

[](#ignored-directories)

By default `phpguard` will ignore `vendor` and also all VCS directories. To add more ignore directories just define `ignores` options in your `phpguard.yml` file.

```
phpguard:
    ignores:
        - build
        - app/cache
        - app/logs
```

### watchers

[](#watchers)

`watch` options allow you to define which files are watched by `phpguard` by using php regular expression patterns:

```
# /path/to/project/phpguard.yml
phpunit:
    watch:
        - { pattern: "#^tests\/(.+)Test\.php$#" }
```

This instructs phpguard to watch for file changes in the tests folder, but only for file names that ends with `Test.php`.

### transform

[](#transform)

You can modify changed file name before sending it to the plugin for processing:

```
phpunit:
    watch:
        - { pattern: "#^src\/(.+)\.php$#", transform: "tests/${1}Test.php }
```

`phpguard` now will use php `preg_replace` function to transform a file change in the `src` folder to it's test case in the `tests` folder.

### Configuration Sample

[](#configuration-sample)

```
# phpguard config section
phpguard:
    ignores: build
    coverage:
        enabled: false
        whitelist:
            - src
        blacklist:
            - spec
            - tests
            - vendor
        show_uncovered_files:   false
        show_only_summary:      false
        output.html:            build/coverage
        output.text:            true
        output.clover:          build/logs/clover.xml

# phpunit config section
phpunit:
    options:
        cli:            "--colors"
        all_on_start:   true
        all_after_pass: true
        keep_failed:    true
        run_all_cli:    "--colors"
    watch:
        - { pattern: "#^src\/(.+)\.php$#", transform: "tests/functional/${1}Test.php" }
        - { pattern: "#^tests\/functional\/.*Test\.php$#" }
# phpspec config section
phpspec:
    options:
        cli:                "--format=pretty"
        all_on_start:       true
        all_after_pass:     true
        keep_failed:        true
        run_all_cli:        "--format=dot -vvv"
    watch:
        - { pattern: "#^src\/(.+)\.php$#", transform: "spec/PhpGuard/Application/${1}Spec.php" }
        - { pattern: "#^spec.*\.php$#" }
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.7% 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://www.gravatar.com/avatar/8e41c1fdde09e273e3c0ef6851041c2663a6655f61a5da543629acd2b7031249?d=identicon)[toni.munthi](/maintainers/toni.munthi)

---

Top Contributors

[![kilip](https://avatars.githubusercontent.com/u/301065?v=4)](https://github.com/kilip "kilip (147 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")

### Embed Badge

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

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

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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