Download the PHP package danrevah/sandbox-bundle without Composer
On this page you can find all versions of the php package danrevah/sandbox-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download danrevah/sandbox-bundle
More information about danrevah/sandbox-bundle
Files in danrevah/sandbox-bundle
Package sandbox-bundle
Short Description SandboxBundle
License MIT
Homepage https://github.com/danrevah/SandboxBundle
Informations about the package sandbox-bundle
SandboxBundle
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
- Installation
- Create a Sandbox environment
- Single response annotation
- Multi response annotation
Installation
The following instructions outline installation using Composer. If you don't have Composer, you can download it from http://getcomposer.org/
- Run either of the following commands, depending on your 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 fileapp_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 lineif (in_array($this->getEnvironment(), array('dev', 'test')))
to this line `if (in_array($this->getEnvironment(), array('dev', 'test','sandbox'))) yml sandbox: response: force: trueForce 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
used in situations when you need a constant response while on sandbox enviorment. the response will always be the same.
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 thetoken.json
instead of the 'foo' from the real getAction(), it won't even go inside.
Multi Response Annotation
used in situations when you need to return different responses depending on the parameters which are being sent.
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 matchingparameters
from the request and if the values are equal, it returns a response with theresource
file mentiond. the parameterstype
andresponseCode
inside themultiResponse
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 themultiResponse
caseParams
has been matched.
All versions of sandbox-bundle with dependencies
symfony/framework-bundle Version ~2.3
symfony/expression-language Version 2.6.4@dev
doctrine/common Version dev-master
danrevah/shortifypunit Version 1.0.*