Download the PHP package tbn/json-annotation-bundle without Composer

On this page you can find all versions of the php package tbn/json-annotation-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package json-annotation-bundle

JsonAnnotationBundle

The JsonAnnotationBundle permits to use an annotation Json for your controller

Usage

Use the annotation @Json() in your controller

Configuration

Some parameters are optionnals:

    json_annotation:
            exception_code: 500 #the http code used for the exception
            data_key: "data" # the key used to contains the data, it can be directly at the root, using the "" parameter
            exception_message_key: "message" #the key for the exeception message
            success_key: "success" #the key for the success (that is true is the result is ok, false for an exception)
            post_query_back: false #do we send back the post parameters
            post_query_key: "query" #the key for the post back parameters
            enable_authentication_error: false #A json response is sent back is the user is not authenticated or not granted

The reponse

The normal response

It is a json stream with the property 'success' with the true value and the property 'data' containing the array returned in the controller

The exception response

It is a json stream with the property 'success' with the false value and the property 'message' containing the error

Examples

Import the bundle using composer

"tbn/json-annotation-bundle": "dev-master"

Import the bundle in your AppKernel

new tbn\JsonAnnotationBundle\JsonAnnotationBundle()

The normal response Example

use tbn\JsonAnnotationBundle\Configuration\Json;

class DefaultController extends Controller
{

     /**
      * The main view
      *
      * @Route("/someroute")
      * @Json()
      *
      * @return array
      */
     public function somerouteAction()
     {
         return array('data1' => 'value1', 'data2' => 'value2');
     }
  }

It will send back a json stream

 'success' => true
 'data'    => ['data1' => 'value1', 'data2' => 'value2']

The exception response

use tbn\JsonAnnotationBundle\Configuration\Json;

 class DefaultController extends Controller
 {
     /**
      * The main view
      *
      * @Route("/someroute")
      * @Json()
      *
      * @return array
      */
     public function somerouteAction()
     {
         throw \Exception('some error occured');
     }
 }

It will send back a json stream

 'success' => false
 'message'    => 'some error occured'

Events

A pre-hook event is dispatched at the beginning of the json response. It can be used to validate a token for example.

some_bundle.listener.json_token_validation_listener:
    class: "some_bundle\\Listener\\JsonTokenValidationListener"
    tags:
        - { name: kernel.event_listener, event: json.pre_hook, method: onJsonPrehook }

The method has one argument of type JsonPreHookEvent.

public function onJsonPrehook(JsonPreHookEvent $jsonPreHookEvent)

All versions of json-annotation-bundle with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tbn/json-annotation-bundle contains the following files

Loading the files please wait ....