PHPackages                             jalbam/fake\_rest\_server - 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. jalbam/fake\_rest\_server

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

jalbam/fake\_rest\_server
=========================

Simple and easy-to-configure REST server made in PHP.

1212PHP

Since Jan 24Pushed 6y ago2 watchersCompare

[ Source](https://github.com/jalbam/fake_rest_server)[ Packagist](https://packagist.org/packages/jalbam/fake_rest_server)[ RSS](/packages/jalbam-fake-rest-server/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

REST server in PHP
==================

[](#rest-server-in-php)

by [Joan Alba Maldonado](https://joanalbamaldonado.com/) (joanalbamaldonadoNO\_SPAM\_PLEASE AT gmail DOT com, without NO\_SPAM\_PLEASE)

Simple and easy-to-configure REST server made in PHP.

Version: no version

- Date: 12th May 2016 (approximately)

Description
-----------

[](#description)

Simple and easy-to-configure REST server made in PHP.

I made it just to create different REST servers very fast for testing purposes.

Configuring the server
----------------------

[](#configuring-the-server)

To add new paths (routes) and methods, the developer just needs to create a new folder structure (folder and subfolders if needed) which represents the route and inside one file per method named *\[method\_desired\].php* (for example, *put.php*).

To start developing your REST server, you will only need to download the files inside the **[src/](src/)** folder.

You may want to take a look at the **[src/\_code/functions.php](src/_code/functions.php)** file (the engine will include it automatically) as it provides some basic but useful functions. There you can also add new functions or modify the existing ones.

If you want to add data, you can use the **[src/\_code/data/data.php](src/_code/data/data.php)** file (automatically included by the engine).

If you want to add configuration data, you can use the **[src/\_code/config.php](src/_code/config.php)** file (automatically included by the engine).

As the engine defines the **USING\_REST\_SERVER** constant, you can protect any of the files with the following line at the beginning:

```

```

Note: this authorization code above is also defined in the **AUTHORIZATION\_CODE** constant (inside the the **[src/\_code/config.php](src/_code/config.php)** file).

### Example:

[](#example)

1. In the root folder (where the **[src/\_code/](src/_code/)** folder and the **[src/index.php](src/index.php)** file are placed), create a folder called **myRESTService/**.
2. Inside the **myRESTService/** folder we have just created, create another folder called **user/** and inside of it create two files: **index.php** and **get.php**.
3. Inside the **myRESTService/user/index.php** file, place the following code:

```
