PHPackages                             dvnc0/chaos-gremlin - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. dvnc0/chaos-gremlin

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dvnc0/chaos-gremlin
===================

A chaos agent for PHP

v0.2.0(2y ago)37UnlicensePHPPHP &gt;=7.4

Since Mar 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/dvnc0/chaos-gremlin)[ Packagist](https://packagist.org/packages/dvnc0/chaos-gremlin)[ RSS](/packages/dvnc0-chaos-gremlin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

```
   )\.-.       .'(     /`-.      .-./(    )\.--.          )\.-.      /`-.   )\.---.   )\   )\   .')      .'(   )\  )\
 ,' ,-,_)  ,') \  )  ,' _  \   ,'     )  (   ._.'       ,' ,-,_)   ,' _  \ (   ,-._( (  ',/ /  ( /       \  ) (  \, /
(  .   _  (  '-' (  (  '-' (  (  .-, (    `-.`.        (  .   __  (  '-' (  \  '-,    )    (    ))       ) (   ) \ (
 ) '..' )  ) .-.  )  )   _  )  ) '._\ )  ,_ (  \        ) '._\ _)  ) ,_ .'   ) ,-`   (  \(\ \   )'._.-.  \  ) ( ( \ \
(  ,   (  (  ,  ) \ (  ,' ) \ (  ,   (  (  '.)  )      (  ,   (   (  ' ) \  (  ``-.   `.) /  ) (       )  ) \  `.)/  )
 )/'._.'   )/    )/  )/    )/  )/ ._.'   '._,_.'        )/'._.'    )/   )/   )..-.(       '.(   )/,__.'    )/     '.(

```

Chaos Gremlin
=============

[](#chaos-gremlin)

Chaos Gremlin is a PHP chaos testing tool, it introduces random problems into your application that simulate latency, CPU use, memory use, high disk use etc. This tool is for testing how well your application recovers from unknown events.

**USE WITH CAUTION** some of these Gremlins will not stop until you manually kill the process. Enable only the Gremlins you want to use and review the settings.

**THIS IS INTENDED FOR TESTING YOUR OWN APPLICATIONS OR APPLICATIONS YOU HAVE PERMISSION TO TEST**

Install with: `composer require dvnc0/chaos-gremlin`

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

[](#requirements)

- PHP `pcntl` extension must be installed.
- The log directory must be writable by the PHP process.
- The Disk Gremlin directory must be writable by the PHP process.

Default Settings
----------------

[](#default-settings)

```
protected array $settings = [
	'probability' => 30,
	'min_latency_seconds' => 2,
	'max_latency_seconds' => 10,
	'exception_message' => 'Chaos Gremlin Exception',
	'dice_roll_over_under' => 3.5,
	'max_memory_percent' => 90,
	'disk_gremlin_directory' => '',
	'disk_gremlin_number_files' => 100,
	'disk_gremlin_file_size' => 5 * 1024 * 1024,
	'traffic_requests' => 100,
	'traffic_url' => 'http://localhost:8080',
	'log_directory' => '',
	'traffic_gremlin_spawns_gremlins' => false,
];
```

These are the default settings for Chaos Gremlin and can be changed by using the `settings` method. We will cover that later in this README.

SettingDescriptionprobabilityThe probability a Gremlin will be released into the systemmin\_latency\_secondsThe minimum latency a Latency\_Gremlin should addmax\_latency\_secondsThe maximum latency a Latency\_Gremlin should addexception\_messageThe message that will be thrown with the Exception\_Gremlindice\_roll\_over\_underThe number that the dice will roll over or under to release a Gremlinmax\_memory\_percentThe maximum memory percentage that the Memory\_Gremlin will usedisk\_gremlin\_directory REQUIREDThe directory that the Disk\_Gremlin will create files indisk\_gremlin\_number\_filesThe number of files the Disk\_Gremlin will createdisk\_gremlin\_file\_sizeThe size of the files the Disk\_Gremlin will createtraffic\_requestsThe number of requests the Traffic\_Gremlin will maketraffic\_urlThe URL the Traffic\_Gremlin will make requests tolog\_directory REQUIREDThe directory that the logs will be saved totraffic\_gremlin\_spawns\_gremlinsIf the Traffic\_Gremlin should spawn other Gremlins, this can get out of hand quickUsing Chaos Gremlin
-------------------

[](#using-chaos-gremlin)

To use Chaos Gremlin you will need to create an instance of the Gremlin class, enable any Gremlins you would like to use, and then call the `release` method. This may release the Gremlins into your application.

```
