PHPackages                             jworkman/scaffold-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. [HTTP &amp; Networking](/categories/http)
4. /
5. jworkman/scaffold-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

jworkman/scaffold-bundle
========================

Symfony Scaffold Bundle

v1.0.2(9y ago)0581[3 issues](https://github.com/jworkman/ScaffoldBundle/issues)MITPHPPHP &gt;=5.4.0

Since Aug 4Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jworkman/ScaffoldBundle)[ Packagist](https://packagist.org/packages/jworkman/scaffold-bundle)[ Docs](https://github.com/jworkman/ScaffoldBundle)[ RSS](/packages/jworkman-scaffold-bundle/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (17)Used By (0)

ScaffoldBundle
==============

[](#scaffoldbundle)

ScaffoldBundle gives you the ability to build quick CRUD functionality inside of your Symfony application. It also gives you the ability to serve JSON responses from each scaffold. Taking some of the best parts of Ruby on Rails and Symfony put together. With ScaffoldBundle you can generate easy flexible CRUD functionality around your Doctrine entities.

Requirements
------------

[](#requirements)

php version &gt;= 5.4 Symfony version &gt;= 2.7

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

[](#installation)

With composer you can install the bundle by running the following in the root of your Symfony project:

```
composer require jworkman/scaffold-bundle

```

You must add the bundle to your `app/AppKernel.php`.

```
$bundles = array(
    ...
    new JWorkman\ScaffoldBundle\JWorkmanScaffoldBundle(),
);

```

Thats it! The bundle should be installed. Now you can move on to creating some scaffolds of your own.

Getting Started
---------------

[](#getting-started)

In order to generate a scaffold you must have some Doctrine entities defined in your project. Lets say we have an entity called "UserProfile" defined in our `AcmeBundle` bundle. We must refer to that entity as `AcmeBundle:UserProfile`. We can run our scaffold generator command on that model to generate a scaffold controller.

```
app/console scaffold:generate

```

The first question is to specify an entity to build a scaffold for. In our case it will be `AcmeBundle:UserProfile`.

```
The Entity shortcut name: AcmeBundle:UserProfile

```

The Second question is asking what friendly name you would like to use for your Scaffold. This should be a user readable title for this scaffold. It will be displayed across all CRUD views as a common name for the entity you are scaffolding.

Note: this value should be a singular (not plural).

```
Specify a friendly common title to use [User Profile]:

```

The third question will ask you what routing prefix you would like to use for this scaffold. In our example if we were editing a UserProfile at `/user_profile/4/edit` then `user_profile` is our prefix. It is the unique scope/namespace for our scaffold.

```
Specify a routing prefix to mount this scaffold [user_profile]:

```

The next question will ask you if you want to lock down any CRUD functionality for this scaffold. Read the documentation above the question for more information. You will have to list out all the methods you want locked down in a comma separated format.

```
What HTTP do you want to disable (comma separated)? none

// Or if you want to disable the index, and edit actions

What HTTP do you want to disable (comma separated)? index,edit

```

The fifth question will ask you if you want to hide any specific fields from the index action. This DOES not hide the fields from the edit, or new actions. This is useful if you have something like passwords that you want to hide from the index action, but not the edit, or new forms. Below we will disable the field "password"

```
Specify any field you would like to make private (Enter nothing to stop adding fields): password

```

The next few questions will go through each field on your entity and ask you what form field type to use for that field. Most of the time the generator will generate intelligent defaults based on your entity field types. This can be adjusted later.

Once you are done defining your form field types it will ask you if you would like to enable the JSON api feature for this specific scaffold. Its a good practice to keep this disabled if you do not use it. In our case we will enable it.

```
Would you like to enable the JSON API for this scaffold? Yes

```

We need to define a target bundle. This defaults to the bundle that the entity is located in, but can be overridden to a different bundle. This is useful if you have a specifc bundle you want to place all of your scaffolds in instead of separate bundles.

```
Specify a target bundle for the controller [AcmeBundle]:

```

Updating the routes is next. In order for the scaffold controller to map requests to it correctly it needs to append some routes to your target bundle's `routing.yml` file. It will ask if you want it to do it for you automatically. You will notice some new routes at the end of the file once this is done.

```
Would you like to automatically update your routes as well? Y

```

After the generator has completed you will notice it placed a new controller in your target bundle. In our case it was `src/AcmeBundle/Controller/UserProfileController.php`. If you open it up it will look something like this:

```
