PHPackages                             danrevah/sandbox-bundle - 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. danrevah/sandbox-bundle

ActiveLibrary

danrevah/sandbox-bundle
=======================

SandboxBundle

v1.0.0(11y ago)18221MITPHPPHP &gt;=5.5.0

Since Feb 22Pushed 7y ago4 watchersCompare

[ Source](https://github.com/danrevah/SandboxBundle)[ Packagist](https://packagist.org/packages/danrevah/sandbox-bundle)[ Docs](https://github.com/danrevah/SandboxBundle)[ RSS](/packages/danrevah-sandbox-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

SandboxBundle
==============

[](#sandboxbundle-)

[![Build Status](https://camo.githubusercontent.com/e4e60822d51f05c24c46107eb3d8530181bc6565948918b7265fde7aa8c768a8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e72657661682f53616e64626f7842756e646c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/danrevah/SandboxBundle/build-status/master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/044c94e6022a4af549fa63c52811c474b8aaf41ff8935fae30ddefbb46afd195/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616e72657661682f53616e64626f7842756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/danrevah/SandboxBundle/?branch=master) [![Latest Stable Version](https://camo.githubusercontent.com/952c8514c2541a4c5b2e06a4c60edca7a261bf10419183b6660c41845c7fd287/68747470733a2f2f706f7365722e707567782e6f72672f64616e72657661682f73616e64626f782d62756e646c652f762f737461626c652e737667)](https://packagist.org/packages/danrevah/sandbox-bundle) [![SensioLabsInsight](https://camo.githubusercontent.com/325d6e76a6e7a28eeebfc6551f5d66f96e687c64ec570430011de27c46eda7f6/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33343061363638662d303561302d343761372d623565322d6335373461336237653533642f6d696e692e706e67)](https://insight.sensiolabs.com/projects/340a668f-05a0-47a7-b5e2-c574a3b7e53d)

> SandboxBundle is a Symfony2 Bundle which is mostly used in conditions when you don't want to reach your real controller in a sandbox / testing environment.

> For example, if you have a controller which handles some action let's say a purchase, you could use a fake response instead of creating a real purchase request. Only by using annotations and in your sandbox / testing environment the controller will be overriden with the response you choose (in JSON or XML format).

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Create a Sandbox environment](#create-a-sandbox-environment)
- [Single response annotation](#single-response-annotation)
- [Multi response annotation](#multi-response-annotation)

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

[](#installation)

The following instructions outline installation using Composer. If you don't have Composer, you can download it from

- Run either of the following commands, depending on your environment:

```
$ composer require "danrevah/sandbox-bundle":"dev-master"
$ php composer.phar require "danrevah/sandbox-bundle":"dev-master"

```

Create a Sandbox environment
----------------------------

[](#create-a-sandbox-environment)

- Copy the file from your `project-root-directory/web/app_dev.php` into the same directory and call the new file `app_sandbox.php`.
- In the file you've just created `app_sandbox.php` change this line `$kernel = new AppKernel('dev', true); ` to this line `$kernel = new AppKernel('sandbox', true); `
- Go to `project-root-directory/app/AppKernel.php` and change this line `if (in_array($this->getEnvironment(), array('dev', 'test'))) ` to this line `if (in\_array($this-&gt;getEnvironment(), array('dev', 'test','sandbox'))) ```
- In the AppKernel.php file after the `if case` you've just edited, add this `if case` also:

```
    if (in_array($this->getEnvironment(), array('sandbox'))) {
        $bundles[] = new danrevah\SandboxBundle\SandboxBundle();
    }
```

- Copy the file from `project-root-directory/app/config/config_dev.yml` and call it `config_sandbox.yml`.
- Add this to the end of your `config_sandbox.yml`:

```
    sandbox:
      response:
        force: true
        # Force mode means you won't be able to "fall"
        # to the REAL controller if a Sandbox response is not available.
        # It will produce an error instead.
```

- **That's it! you can now access your sandbox environment using `app_sandbox.php`**

Single Response Annotation
--------------------------

[](#single-response-annotation)

used in situations when you need a constant response while on sandbox enviorment. the response will always be the same.

```
    /**
     * GET /resource
     *
     * @ApiSandboxResponse(
     *      responseCode=200,
     *      type="json",
     *      parameters={
     *          {"name"="some_parameter", "required"=true}
     *      },
     *      resource="@SandboxBundle/Resources/responses/token.json"
     * )
     */
    public function getAction() {
        return array('foo');
    }
```

- `responseCode` (default = 200) - it's the Http response code of the Sandbox response.
- `type` (default = 'json') - you can choose between 'json' and 'xml'.
- `parameters` (default = array()) - this is used to validate required parameters in the Sandbox API in order to produce an Exception if the parameter is missing.
- `resource` (**required**) - the real controller will be overwritten by this, in the above example it will ALWAYS return the contents of the `token.json` instead of the 'foo' from the real getAction(), it won't even go inside.

Multi Response Annotation
-------------------------

[](#multi-response-annotation)

used in situations when you need to return different responses depending on the parameters which are being sent.

```
    /**
     * POST /resource
     *
     * @ApiSandboxMultiResponse(
     *      responseCode=200,
     *      type="json",
     *      parameters={
     *          {"name"="some_parameter", "required"=true}
     *      },
     *      responseFallback={
     *          "type"="xml",
     *          "responseCode"=500,
     *          "resource"="@SandboxBundle/Resources/responses/error.xml"
     *      },
     *      multiResponse={
     *          {
     *              "type"="xml",
     *              "resource"="@SandboxBundle/Resources/responses/token.xml",
     *              "caseParams": {"some_parameter"="1", "some_parameter2"="2"}
     *          },
     *          {
     *              "resource"="@SandboxBundle/Resources/responses/token.json",
     *              "caseParams": {"some_parameter"="3", "some_parameter2"="4"}
     *          }
     *      }
     * )
     */
    public function postAction() {
        return array('bar');
    }
```

- `responseCode` (default = 200) - it's the Http response code of the Sandbox response.
- `type` (default = 'json') - you can choose between 'json' and 'xml'.
- `parameters` (default = array()) - this is used to validate required parameters in the Sandbox API in order to produce an Exception if the parameter is missing.
- `multiResponse` (**required**) - used to find matching `parameters` from the request and if the values are equal, it returns a response with the `resource` file mentiond. the parameters `type` and `responseCode` inside the `multiResponse` are not required it will use the parent parameters if none is found inside a matching case.
- `responseFallback` (**required**) - it's using this response when none of the `multiResponse` `caseParams` has been matched.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

4102d ago

### Community

Maintainers

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

---

Top Contributors

[![danrevah](https://avatars.githubusercontent.com/u/7808742?v=4)](https://github.com/danrevah "danrevah (152 commits)")

---

Tags

annotationsphpphp7symfonysymfony2

### Embed Badge

![Health badge](/badges/danrevah-sandbox-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/danrevah-sandbox-bundle/health.svg)](https://phpackages.com/packages/danrevah-sandbox-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[artgris/filemanager-bundle

FileManager is a simple Multilingual File Manager Bundle for Symfony

182420.8k9](/packages/artgris-filemanager-bundle)

PHPackages © 2026

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