PHPackages                             jelix/fakeserverconf - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. jelix/fakeserverconf

ActiveLibrary[Testing &amp; Quality](/categories/testing)

jelix/fakeserverconf
====================

Fill the $\_SERVER array with various PHP server configuration for unit tests.

v1.0.0(11y ago)11115.5k↓19.3%1MITPHPPHP &gt;=5.3.0

Since Nov 15Pushed 11y ago3 watchersCompare

[ Source](https://github.com/jelix/FakeServerConf)[ Packagist](https://packagist.org/packages/jelix/fakeserverconf)[ RSS](/packages/jelix-fakeserverconf/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (1)Versions (3)Used By (1)

This PHP Library will allow you to simulate different PHP server configuration.

In a CLI environment (where you run PHPUnit for instance), you could have some difficulties to test a class that uses some $\_SERVER values. This global variable does not contain the same thing as if the script is called in an Apache environment for example. Moreover the content of $\_SERVER is not the same between a server configured with mod\_php, and a server running PHP as a CGI, as FPM etc..

FakeServerConf allow you to fill automatically $\_SERVER with good values (and $\_GET, $\_POST...), only by given an URL to "virtual" PHP server.

You don't need anymore to setup several real PHP HTTP server to test your libraries in different environment. Just call FakeServerConf in your unit tests.

For example, in your test, you want to have a $\_SERVER filled as if the URL "" was requested. In your PHPUnit/Atoum/Simpletest/whatever class, call this:

```
    // let's says we are running an Apache server configured with mod_php.
    // Indicate to this server the script name (it can be hidden in the http request)
    $server = new \Jelix\FakeServerConf\ApacheMod(null, '/info.php');

    // now simulate an HTTP request
    $server->setHttpRequest('http://testapp.local/info.php/foo/bar?baz=2');
```

$\_SERVER is now filled correctly, and you can test your classes (routers, url parser etc...)

You can also set the document root and other things...

Supported servers
-----------------

[](#supported-servers)

- Apache + mod\_php
- Apache + php-cgi
- Apache + mod\_fastcgi + php-fpm

Adding servers
--------------

[](#adding-servers)

You don't find your server configuration in FakeServerConf? Help us to provide additionnal support.

- First configure your server. It's better if it's a fresh installation in a virtual machine. You should install the curl extension for php.
- Configure a virtual host named "testapp.local". It should accept multiviews queries (without .php)
- The document root of the server should be /var/www/ and it should content files you can find in tests/[www](http://www). You can also set the document root to tests/[www](http://www).
- In your browser, call . It generates some PHP code that you have to add into a test class in tests/. See existing test class.
- Create a new class in src/jelix/FakeServerConf, that inherits from FakeServerConf
- In your test class, you should instantiate this class
- Run tests with phpunit, and fix in your new class the issues detected in your tests.
- Don't touch the FakeServerConf class except if it makes sens for all server configuration.

installing
----------

[](#installing)

You can use Composer. Into your composer.json file, add

```
"require": {
    "jelix/fakeserverconf": "1.0.0"
}

```

running test
------------

[](#running-test)

Install phpunit (run composer install) and launch it into the tests/ directory

```
cd tests
../vendor/bin/phpunit
# or if you installed phpunit globally:
phpunit

```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~839 days

Total

2

Last Release

4139d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae8142be36568660282368ce7c1eec904ecbc515ab5b58c759a487f3a6f1d114?d=identicon)[laurentj](/maintainers/laurentj)

---

Top Contributors

[![laurentj](https://avatars.githubusercontent.com/u/336034?v=4)](https://github.com/laurentj "laurentj (11 commits)")

---

Tags

\_SERVER PHP configuration unit tests

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[dms/phpunit-arraysubset-asserts

This package provides ArraySubset and related asserts once deprecated in PHPUnit 8

14429.2M360](/packages/dms-phpunit-arraysubset-asserts)

PHPackages © 2026

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