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

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

bpa/api-sandbox-bundle
======================

Symfony Bundle for easy creation of API Sandboxes and integration with NelmioApiDocBundle

v0.21(8y ago)394PHP

Since Jan 3Pushed 7y ago1 watchersCompare

[ Source](https://github.com/BenjaminPaap/ApiSandboxBundle)[ Packagist](https://packagist.org/packages/bpa/api-sandbox-bundle)[ RSS](/packages/bpa-api-sandbox-bundle/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

API Sandbox Bundle
==================

[](#api-sandbox-bundle)

This bundle is designed to prevent requests using your real controllers and responding with a fake response you defined. It integrates nicely with `NelmioApiDocBundle` and `FOSRestBundle`.

When using `NelmioApiDocBundle` this bundle will generate `curl` examples for your provided sandbox requests automatically which will show in the documentation.

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

[](#requirements)

ApiSandboxBundle requires php &gt;= 5.5 and symfony &gt;= 2.7.

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

[](#installation)

The easiest way to install this library is through [composer](http://getcomposer.org/). Just add the following lines to your **composer.json** file and run `composer.phar update`:

```
{
   "require": {
        "bpa/api-sandbox-bundle": "dev-master"
    }
}
```

Configuration
-------------

[](#configuration)

Load the bundle in your `AppKernel.php`:

```
class AppKernel extends Kernel {
    public function registerBundles() {
        // ...
        $bundles = [
            // ...
            new Bpa\ApiSandboxBundle\ApiSandboxBundle(),
            // ...
        ];
        // ...
    }
}
```

I would recommend to create a new environment for your sandbox by copying the `app.php` front controller to something like `app_sandbox.php`. In your new front controller you have to change the following line to the new environment:

```
$kernel = new AppKernel('sandbox', false);
```

Create a new `config_sandbox.yml` in your `app/config` directory with the following contents:

```
imports:
    - { resource: config_prod.yml }

api_sandbox:
    enabled: true
    force_response: true
```

This takes all settings from your `prod` environment and enables the sandbox for your new `sandbox`environment.

Usage
-----

[](#usage)

### A basic Controller

[](#a-basic-controller)

When using the `FOSRestBundle` and `NelmioApiDocBundle` for your API an integration within your application could look something like this:

```
