2017 © Pedro Peláez
 

symfony-bundle webapi-bundle

Create a JSON WebApi with minimum configuration, targetting several client side libraries, such as breeze js

image

adrotec/webapi-bundle

Create a JSON WebApi with minimum configuration, targetting several client side libraries, such as breeze js

  • Friday, April 6, 2018
  • by mrsafraz
  • Repository
  • 3 Watchers
  • 5 Stars
  • 12,550 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 3 Versions
  • 4 % Grown

The README.md

Project Status: 🚨 Unmaintained 🚨

This project is no longer maintained. We will not be accepting pull requests, addressing issues, nor making future releases., (*1)

AdrotecWebApiBundle

This is a Symfony 2bundle to create Web APIs with breeze.server.php, (*2)

Usage

Install with composer

    "require": {
      "adrotec/webapi-bundle": "dev-master",
      "symfony/validator": "dev-master"
    }

"symfony/validator": "dev-master" is required for validations with breeze.server.php to work properly, (*3)

Enable the bundle in AppKernel.php

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new JMS\SerializerBundle\JMSSerializerBundle(),
        new Adrotec\WebApiBundle\AdrotecWebApiBundle(),
        // ...
    );
}

The order is important here because AdrotecWebApiBundle overrides some of the JMSSerializerBundle behaviours. E.g: Naming strategy, Lazy loading, etc., (*4)

Create an API controller

Add routing configuration, (*5)

# src/EmpDirectory/Bundle/Resources/config/routing.yml
emp_directory_api:
    path:       /api/{resource}
    defaults:   { _controller: EmpDirectoryBundle:Api:api }

the request parameter {resource} is important here, since it is used by the library to identify the current request resource., (*6)

The bundle exposes a service named adrotec_webapi which you can use in your controller., (*7)


// src/EmpDirectory/Bundle/Controller/ApiController.php namespace EmpDirectory\Bundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; class ApiController extends Controller { public function apiAction(Request $request) { $api = $this->container->get('adrotec_webapi'); $api->addResources(array( 'Employees' => 'EmpDirectory\Bundle\Entity\Employee', 'Departments' => 'EmpDirectory\Bundle\Entity\Department', 'Jobs' => 'EmpDirectory\Bundle\Entity\Job', )); // $request->attributes->set($request->attributes->get('resource')); $response = $api->handle($request); return $response; } }

The Versions

06/04 2018

dev-master

9999999-dev http://github.com/adrotec/AdrotecWebApiBundle

Create a JSON WebApi with minimum configuration, targetting several client side libraries, such as breeze js

  Sources   Download

MIT

The Requires

 

by Muhammad Safraz Razik

api json rest webapi breeze odata breezejs

12/10 2015

1.0.5

1.0.5.0 http://github.com/adrotec/AdrotecWebApiBundle

Create a JSON WebApi with minimum configuration, targetting several client side libraries, such as breeze js

  Sources   Download

MIT

The Requires

 

by Muhammad Safraz Razik

api json rest webapi breeze odata breezejs

20/10 2014

1.0.2

1.0.2.0 http://github.com/adrotec/AdrotecWebApiBundle

Create a JSON WebApi with minimum configuration, targetting several client side libraries, such as breeze js

  Sources   Download

MIT

The Requires

 

by Muhammad Safraz Razik

api json rest webapi breeze odata breezejs