Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

restgeneratorbundle

> 编程语言
Open source

A CRUD like REST Generator Bundle for Symfony 2

177 stars0 likes1 views
WebsiteGitHub

About

A CRUD like REST Generator Bundle for Symfony 2

Voryx REST Generator Bundle

About

A CRUD like REST Generator

Features

  • Generators RESTful action from entity
  • Simplifies setting up a RESTful Controller

Installation

Require the "voryx/restgeneratorbundle" package in your composer.json and update your dependencies.

bash
$ php composer.phar require voryx/restgeneratorbundle dev-master

Add the VoryxRestGeneratorBundle to your application's kernel along with other dependencies:

php
public function registerBundles()
{
    $bundles = array(
        //...
          new Voryx\RESTGeneratorBundle\VoryxRESTGeneratorBundle(),
          new FOS\RestBundle\FOSRestBundle(),
          new JMS\SerializerBundle\JMSSerializerBundle($this),
          new Nelmio\CorsBundle\NelmioCorsBundle(),
        //...
    );
    //...
}

Configuration

This bundle depends on a number of other Symfony bundles, so they need to be configured in order for the generator to work properly

…

Generating the Controller

Generate the REST controller

bash
$ php app/console voryx:generate:rest

This will guide you through the generator which will generate a RESTful controller for an entity.

Example

Create a new entity called 'Post':

bash
$ php app/console doctrine:generate:entity --entity=AppBundle:Post --format=annotation --fields="name:string(255) description:string(255)" --no-interaction

Update the database schema:

bash
$ php app/console doctrine:schema:update --force

Generate the API controller:

bash
$ php app/console voryx:generate:rest --entity="AppBundle:Post"

Using the API

If you selected the default options you'll be able to start using the API like this:

Creating a new post (POST)

bash
$ curl -i -H "Content-Type: application/json" -X POST -d '{"name" : "Test Post", "description" : "This is a test post"}' http://localhost/app_dev.php/api/posts

Updating (PUT)

bash
$ curl -i -H "Content-Type: application/json" -X PUT -d '{"name" : "Test Post 1", "description" : "This is an updated test post"}' http://localhost/app_dev.php/api/posts/1

Get all posts (GET)

bash
$ curl http://localhost/app_dev.php/api/posts

Get one post (GET)

bash
$ curl http://localhost/app_dev.php/api/posts/1

Delete (DELETE)

bash
$ curl -X DELETE  http://localhost/app_dev.php/api/posts/1

Related Entities

If you want the form to be able to convert related entities into the correct entity id on POST, PUT or PATCH, use the voryx_entity form type

php
#Form/PostType()

    ->add(
        'user', 'voryx_entity', array(
            'class' => 'Acme\Bundle\Entity\User'
        )
    )

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHP

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言