PHPackages                             funct-gmbh/php-watcher - 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. [CLI &amp; Console](/categories/cli)
4. /
5. funct-gmbh/php-watcher

ActiveLibrary[CLI &amp; Console](/categories/cli)

funct-gmbh/php-watcher
======================

Automatically restart PHP application once the source code changes

v1.0.1(4y ago)066911MITPHPPHP ^7.4|^8.0

Since Oct 4Pushed 4y agoCompare

[ Source](https://github.com/funct/php-watcher)[ Packagist](https://packagist.org/packages/funct-gmbh/php-watcher)[ RSS](/packages/funct-gmbh-php-watcher/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (13)Versions (15)Used By (1)

PHP-watcher
===========

[](#php-watcher)

[![PHP Version](https://camo.githubusercontent.com/0fb89f907babb1a8cef8209feba85161eb61c9c1ff5d80b52fdc385a9b7b2963/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f66756e63742d676d62682f7068702d776174636865722e737667)](https://php.net/)[![Total Downloads](https://camo.githubusercontent.com/ab407a40d9abbbca6bd7f6f76ff38ebb3293f31c4dfa56fc0ac52e34ae8454bc/68747470733a2f2f706f7365722e707567782e6f72672f66756e63742d676d62682f7068702d776174636865722f646f776e6c6f616473)](https://packagist.org/packages/funct-gmbh/php-watcher)

[![Latest Stable Version](https://camo.githubusercontent.com/bac29e7784b31f0765e4efb0e20e619a873af8d90c4d6f96a7ffaa5993d6fb08/68747470733a2f2f706f7365722e707567782e6f72672f66756e63742d676d62682f7068702d776174636865722f762f737461626c65)](https://packagist.org/packages/funct-gmbh/php-watcher)[![Latest Version](https://camo.githubusercontent.com/22ca7222d2164576600f66ce7e2d7f916bfefaf5c27e31dada6860ea12856939/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66756e63742d676d62682f7068702d776174636865722e737667)](https://packagist.org/packages/funct-gmbh/php-watcher)[![Latest Unstable Version](https://camo.githubusercontent.com/f7ea99632d49b5509c2c0f0ca5e271473c162dff132bc24f97bc943b4d7d9833/68747470733a2f2f706f7365722e707567782e6f72672f66756e63742d676d62682f7068702d776174636865722f762f756e737461626c65)](https://packagist.org/packages/funct-gmbh/php-watcher)

[![License](https://camo.githubusercontent.com/1760140d0394dfe1cf168a8d2da2f16a737de7ef67ce41413af2ea1cc901d50b/68747470733a2f2f706f7365722e707567782e6f72672f66756e63742d676d62682f7068702d776174636865722f6c6963656e7365)](https://packagist.org/packages/funct-gmbh/php-watcher)

[![watcher logo](images/watcher.gif)](images/watcher.gif)

PHP-watcher helps develop long-running PHP applications by automatically restarting them when file changes in the directory are detected.

Here's how it looks like:

[![watcher screenshot](images/demo.svg)](images/demo.svg)

PHP-watcher does not require any additional changes to your code or method of development. `php-watcher` is a replacement wrapper for `php`, to use PHP -watcher replace the word `php` in the command line when executing your script.

**Table of contents**

- [Installation](#installation)
- [Usage](#usage)
- [Config files](#config-files)
- [Monitoring multiple directories](#monitoring-multiple-directories)
- [Specifying extension watch list](#specifying-extension-watch-list)
- [Ignoring files](#ignoring-files)
- [Delaying restarting](#delaying-restarting)
- [Default executable](#default-executable)
- [Gracefully reloading down your script](#gracefully-reloading-down-your-script)
- [Automatic restart](#automatic-restart)
- [Spinner](#spinner)

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

[](#installation)

You can install this package globally like this:

```
composer global require funct-gmbh/php-watcher
```

After that phpunit-watcher watch can be run in any directory on your system.

Alternatively, you can install the package locally as a dev dependency in your project:

```
composer require funct-gmbh/php-watcher --dev
```

Locally installed you can run it with `vendor/bin/php-watcher`.

Usage
-----

[](#usage)

All the examples assume you've installed the package globally. If you opted for the local installation prepend `vendor/bin/` everywhere where `php-watcher` is mentioned.

PHP-watcher wraps your application, so you can pass all the arguments you would normally pass to your app:

```
php-watcher [your php app]
```

Using PHP-Watcher is simple. If your application accepts a host and port as the arguments, I can start it using option `--arguments`:

```
php-watcher server.php --arguments localhost --arguments 8080
```

Any output from this script is prefixed with `[php-watcher]`, otherwise all output from your application, errors included, will be echoed out as expected.

Config files
------------

[](#config-files)

PHP-Watcher supports customization of its behavior with config files. The file for options may be named `.php-watcher.yml`, `php-watcher.yml` or `php-watcher.yml.dist`. The tool will look for a file in the current working directory in that order. An alternative local configuration file can be specified with the `--config ` option.

The specificity is as follows, so that a command line argument will always override the config file settings:

- command line arguments
- local config

A config file can take any of the command line arguments, for example:

```
watch:
  - src
  - config
extensions:
  - php
  - yml
ignore:
  - tests
```

Monitoring multiple directories
-------------------------------

[](#monitoring-multiple-directories)

By default, PHP-Watcher monitors the current working directory. If you want to take control of that option, use the `--watch` option to add specific paths:

```
php-watcher --watch src --watch config server.php
```

Now PHP-Watcher will only restart if there are changes in the `./src` or `./config ` directories. By default traverses sub-directories, so there's no need to explicitly include them.

Specifying extension watch list
-------------------------------

[](#specifying-extension-watch-list)

By default, PHP-Watcher looks for files with the `.php` extension. If you use the `--ext` option and monitor `app,yml` PHP-Watcher will monitor files with the extension of `.php` and `.yml`:

```
php-watcher server.php --ext=php,yml
```

Now PHP-Watcher will restart on any changes to files in the directory (or subdirectories) with the extensions `.php`, `.yml`.

Ignoring files
--------------

[](#ignoring-files)

By default, PHP-Watcher will only restart when a `.php` file changes. In some cases you may want to ignore some specific files, directories or file patterns, to prevent PHP-Watcher from prematurely restarting your application.

This can be done via the command line:

```
php-watcher server.php --ignore public/ --ignore tests/
```

Or specific files can be ignored:

```
php-watcher server.php --ignore src/config.php
```

Patterns can also be ignored (but be sure to quote the arguments):

```
php-watcher server.php --ignore 'src/config/*.php'
```

Note that by default, PHP-Watcher ignores all *dot* and VCS files.

Delaying restarting
-------------------

[](#delaying-restarting)

In some situations, you may want to wait until a number of files have changed . The timeout before checking for new file changes is 1 second. If you're uploading a number of files and it's taking some number of seconds, this could cause your app to restart multiple times unnecessarily.

To add an extra throttle, or delay restarting, use the `--delay` option:

```
php-watcher server.php --delay 10
```

For more precision, use a float:

```
php-watcher server.php --delay 2.5
```

Default executable
------------------

[](#default-executable)

By default, PHP-Watcher uses `php` bin executable to run your scripts. If you want to provide your own executable use `--exec` option or `executable` param in config file. This is particularly useful if you're working with several PHP versions.

```
executable: php
```

or using CLI:

```
php-watcher server.php --exec php7
```

### Running non-php scripts

[](#running-non-php-scripts)

PHP-Watcher can also be used to execute and monitor other non-php programs. For example, you can use PHP-Watcher to listen to `*.js` files and use `node` executable to run them:

```
php-watcher server.js --exec node --watch app --ext=js
```

The command above uses NodeJS to start `server.js` and then listens to changes in `app` directory.

Gracefully reloading down your script
-------------------------------------

[](#gracefully-reloading-down-your-script)

It is possible to have PHP-watcher send any signal that you specify to your application.

```
php-watcher --signal SIGTERM server.php
```

Your application can handle the signal as follows:

```
declare(ticks = 1);

pcntl_signal(SIGTERM, 'terminationHandler');

function terminationHandler()
{
    // ...
}
```

By default PHP-watcher sends `SIGINT` signal.

Automatic restart
-----------------

[](#automatic-restart)

PHP-watcher was originally written to restart long-running processes such as web servers, but it also supports apps that cleanly exit. If your script exits cleanly, the watcher will continue to monitor the directory (or directories) and restart the script if there are any changes. If the script crashes PHP-watcher will notify you about that.

[![app exit](images/exit.svg)](images/exit.svg)

Spinner
-------

[](#spinner)

By default the watcher outputs a nice spinner which indicates that the process is running and watching your files. But if your system doesn't support ansi coded the watcher will try to detect it and disable the spinner. Or you can always disable the spinner manually with option '--no-spinner':

```
php-watcher server.php --no-spinner
```

Attribution
-----------

[](#attribution)

Based on the work of [seregazhuk/php-watcher](https://github.com/seregazhuk/php-watcher)

License
=======

[](#license)

MIT

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 88% 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 ~76 days

Recently: every ~204 days

Total

12

Last Release

1620d ago

Major Versions

v0.5.2 → v1.0.02022-01-24

PHP version history (3 changes)v0.2.0PHP ^7.1

v0.3.0PHP ^7.2

v1.0.0PHP ^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1294731?v=4)[Fritz Gerneth](/maintainers/fritz-gerneth)[@fritz-gerneth](https://github.com/fritz-gerneth)

---

Top Contributors

[![seregazhuk](https://avatars.githubusercontent.com/u/9959761?v=4)](https://github.com/seregazhuk "seregazhuk (147 commits)")[![gorbunov](https://avatars.githubusercontent.com/u/198664?v=4)](https://github.com/gorbunov "gorbunov (9 commits)")[![fritz-gerneth](https://avatars.githubusercontent.com/u/1294731?v=4)](https://github.com/fritz-gerneth "fritz-gerneth (8 commits)")[![kpicaza](https://avatars.githubusercontent.com/u/1093654?v=4)](https://github.com/kpicaza "kpicaza (2 commits)")[![mmoreram](https://avatars.githubusercontent.com/u/521409?v=4)](https://github.com/mmoreram "mmoreram (1 commits)")

---

Tags

phpasynchronouscliconsoleclockshellwatcherscriptsbashphp-watcher

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/funct-gmbh-php-watcher/health.svg)

```
[![Health](https://phpackages.com/badges/funct-gmbh-php-watcher/health.svg)](https://phpackages.com/packages/funct-gmbh-php-watcher)
```

###  Alternatives

[seregazhuk/php-watcher

Automatically restart PHP application once the source code changes

395138.9k6](/packages/seregazhuk-php-watcher)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k251.2M24.9k](/packages/friendsofphp-php-cs-fixer)[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k52](/packages/friendsoftypo3-content-blocks)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[alecrabbit/php-console-spinner

Extremely flexible spinner for \[async\] php cli applications

24038.0k2](/packages/alecrabbit-php-console-spinner)

PHPackages © 2026

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