PHPackages                             pportelette/crud-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. pportelette/crud-bundle

ActiveSymfony-bundle[API Development](/categories/api)

pportelette/crud-bundle
=======================

This bundle provides basic CRUD endpoints for Doctrine entities

v0.2.1(1y ago)023MITPHPPHP &gt;=7.2.5

Since Mar 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/pportelette/SymfonyCrudBundle)[ Packagist](https://packagist.org/packages/pportelette/crud-bundle)[ RSS](/packages/pportelette-crud-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (7)Used By (0)

CrudBundle
==========

[](#crudbundle)

This bundle provides basic CRUD endpoints for one given Doctrine entity:

- GET `/entity` returns a paginated result
- GET `/entity/list` returns an array of objects
- GET `/entity/{id}` returns an object
- POST `/entity` creates an entity
- PUT `/entity/{id}` updates an entity
- DELETE `'/entity/{id}` delete an entity

Installation
------------

[](#installation)

Open a command console, enter your project directory and execute:

```
$ composer require pportelette/crud-bundle
```

Applications that don't use Symfony Flex
----------------------------------------

[](#applications-that-dont-use-symfony-flex)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    Pportelette\CrudBundle\PporteletteCrudBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

In the following sections we will consider that we have a simple Doctrine Entity 'Category' with its Doctrine repository 'CategoryRepository'.

```
namespace App\Entity;

use App\Repository\CategoryRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: CategoryRepository::class)]
class Category
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: "integer")]
    private $id;

    #[ORM\Column(type: "string", length: 100)]
    private $name;

    #[ORM\Column(type: "datetime_immutable")]
    private $created_at;

    /*
        GETTERS AND SETTERS
    */
}
```

#### Create ViewModel

[](#create-viewmodel)

First of all is to create a ViewModel object that will represent our entity in the front.

```
namespace App\Model;

use Pportelette\CrudBundle\Model\ViewModel;
use App\Entity\Category;

class CategoryVM extends ViewModel {
    public $id;
    public $name;
    private $createdAt;

    public function fromEntity(Category $category = null): void {
        if(!$category) {
            return;
        }
        $this->id = $category->getId();
        $this->name = $category->getName();
        $this->createdAt = $category->getCreatedAt();
    }

    public function toEntity(Category $category = new Category()): Category {
        $category->setName($this->name);
        $category->setCreatedAt($this->createdAt);

        return $category;
    }

    /**
     * Customize the response for the GET /category endpoint
     * Optional
     */
    public function getAll(): array {
        return [
            'id' => $this->id,
            'name' => $this->name
        ];
    }

    /**
     * Customize the response for the GET /category/list endpoint
     * Optional
     */
    public function getList(): array {
        return [
            'name' => $this->name,
        ];
    }
}
```

#### Extend Repository

[](#extend-repository)

```
namespace App\Repository;

// ...
use Pportelette\CrudBundle\Repository\CrudRepository;

class CategoryRepository extends CrudRepository
{
    // ...
}
```

#### Extend Controller

[](#extend-controller)

```
namespace App\Controller;

// ...
use Pportelette\CrudBundle\Controller\CrudController;

class WordController extends CrudController
{
    public function __construct(SerializerInterface $serializer, CategoryRepository $repository)
    {
        $this->configure(
            $serializer,
            $repository,
            CategoryVM::class
        );
    }
}
```

#### Configure routes

[](#configure-routes)

Drive all requests starting by `/category` to CategoryController.

```
category:
    resource: ../src/Controller/CategoryController.php
    type: attribute
    prefix:   /category
    trailing_slash_on_root: false
```

At this point the 6 CRUD endpoints are available.

#### Custom Service

[](#custom-service)

It is possible to override the service methods.

For this create a service `CategoryService.php` that extends `CrudService` and override a method that complies with the Pportelette\\CrudBundle\\Service\\CrudServiceInterface such as:

```
public function getAll(int $page, array $filters = []): Pageable;
public function getList(array $filters = []): array;
public function getEntity(int $id): ViewModel;
public function createEntity(array $properties): ViewModel;
public function updateEntity(int $id, array $properties): ViewModel;
public function deleteEntity(int $id): void;
```

```
// src/Service/CategoryService.php
// ...
use Pportelette\CrudBundle\Service\CrudService;
use Pportelette\PageableBundle\Model\Pageable;

class WordService extends CrudService
{
    public function __construct(CategoryRepository $wordRepository)
    {
        parent::__construct($wordRepository, CategoryVM::class);
    }

    public function getAll(int $page, array $params = []): Pageable
    {
        // Your custom code
    }
}
```

#### Custom Repository

[](#custom-repository)

It is possible to override the repository methods.

Your repository already extends the CrudRepository. Simply add a method that complies with the Pportelette\\CrudBundle\\Repository\\CrudRepositoryInterface:

```
public function getAll(int $page, array $filters = []): Pageable;
public function getList(array $filters = []): array;
```

```
// src/Repository/CategoryRepository.php

// ...

public function getAll(int $page, array $filters = []): Pageable
{
    $qb = $this->createQueryBuilder('w');

    // Your custom code

    return $this->getPage(
        $qb,
        $page
    );
}
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~62 days

Recently: every ~78 days

Total

6

Last Release

542d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7ebba3a51a057248a4e1e8989657782b3d41c474b13b6ada52b927077f27cd4?d=identicon)[pportelette](/maintainers/pportelette)

---

Top Contributors

[![pportelette](https://avatars.githubusercontent.com/u/20822596?v=4)](https://github.com/pportelette "pportelette (7 commits)")

### Embed Badge

![Health badge](/badges/pportelette-crud-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/pportelette-crud-bundle/health.svg)](https://phpackages.com/packages/pportelette-crud-bundle)
```

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M733](/packages/sylius-sylius)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k13](/packages/2lenet-crudit-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
