PHP Mock Repository

From F-Droid
Jump to: navigation, search

For testing of repositories that support HTTP Auth, this PHP script may come in handy. It exposes two repositories, one requiring HTTP Auth, the other doesn't. The HTTP Auth repository will accept any username/password combination as it is just for testing.


This uses PHPs build in web server, which is run with the following command:

php -S router.php

Make sure to change the IP address to the address of your server (likely on the local network). Don't bind to localhost or because a separate device such as your Android phone will not be able to connect.

The router.php script is as follows:

$auth = '/auth';
if (substr($_SERVER['REQUEST_URI'], 0, strlen($auth)) == $auth) {
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
        header('WWW-Authenticate: Basic realm="F-Droid Server"');
        header('HTTP/1.0 401 Unauthorized');
return false;

Directory Structure

To use it, create the following directory structure:

  • auth
    • fdroid
      • repo
  • regular
    • fdroid
      • repo
  • router.php

And make sure that you have all files required to make an F-Droid server inside the respective repo directories (index.jar, relevant .apk files, etc). One could just be a symlink of the other if you want.

Adding Repositories to Client

Once this is all setup, and your PHP server is running, add repos using the following addresses:


Substituting the IP address with the one you used to start the PHP server.