Search by

arguv / crud-api-bundle

arguv

Symfony bundle for CRUD API

Package info

github.com/arguv/crud-api-bundle

Type:symfony-bundle

pkg:composer/arguv/crud-api-bundle

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-master 2026-11-11 09:59 UTC

README

Packagist

Reusable Symfony 3.4 bundle providing a JSON CRUD API for the Product entity.

Requirements

  • PHP 7.3 or newer
  • Symfony 3.4
  • Doctrine ORM 2.5 or newer

Installation

Install the bundle with Composer:

composer require arguv/crud-api-bundle:dev-master

Register it in AppKernel.php:

public function registerBundles()
{
    $bundles = array(
        // ...
        new Arguv\CrudApiBundle\CrudApiBundle(),
    );

    return $bundles;
}

Enable the bundle routes:

arguv_crud_api:
    resource: '@CrudApiBundle/Controller/'
    type: annotation

Create the Doctrine table in the host application:

php bin/console doctrine:schema:update --force

API endpoints

Method Endpoint Description
GET /arguv/list Return all products
GET /arguv/list/{id} Return one product
POST /arguv/create Create a product
POST /arguv/update/{id} Update a product
POST /arguv/delete/{id} Delete a product

The {id} parameter must be numeric. Missing products return a JSON response with HTTP status 404.

Request body

Create and update requests require name and description string values. The product name cannot exceed 100 characters. The API accepts either a single JSON object or the documented one-item array:

{
  "name": "Smith",
  "description": "Willard Carroll Smith Jr. is an American actor and rapper."
}
[
  {
    "name": "Smith",
    "description": "Willard Carroll Smith Jr. is an American actor and rapper."
  }
]

Successful responses use this structure:

{
  "result": "success",
  "description": "Record created successfully",
  "code": 200,
  "data": "Record created successfully"
}

Missing records use this structure:

{
  "result": "error",
  "description": "No product found in the database with the given id - 10",
  "code": 404,
  "data": []
}

Development

Install development dependencies and run the test suite with:

composer install
vendor/bin/phpunit

Tests are located in Arguv/CrudApiBundle/tests.