Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Webapi Bundle Laravel Package

adrotec/webapi-bundle

Unmaintained Symfony 2 bundle for building web APIs with breeze.server.php. Registers an adrotec_webapi service to map request resources to entities and handle API requests, while overriding some JMSSerializerBundle behaviors (naming, lazy loading, etc.).

View on GitHub
Deep Wiki
Context7

Project Status: 🚨 Unmaintained 🚨

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

AdrotecWebApiBundle

This is a Symfony 2bundle to create Web APIs with breeze.server.php

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

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.

Create an API controller

Add routing configuration

# 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.

The bundle exposes a service named adrotec_webapi which you can use in your controller.


// 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;
    }

}

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware