2017 © Pedro Peláez
 

symfony-bundle meat-up

Code generator for Symfony2

image

ip/meat-up

Code generator for Symfony2

  • Wednesday, July 26, 2017
  • by interpunkt
  • Repository
  • 1 Watchers
  • 2 Stars
  • 40 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

MeatUp Bundle

The MeatUp Bundle is a Symfony bundle that provides a command for generating a CRUD controller based on a Doctrine Entity. It uses the Symfony Skeleton Application from inter-Punkt as a starting basis. The bundle will generate the following files for you:, (*1)

  • A FormType based on a Doctrine Entity and some of MeatUps annotations
  • A Controller for the CRUD operations
  • A view file for a tabular presentation of all records
  • View files for creating and updating records

Basic Usage

This guide will show you who to generate a CRUD Controller from a simple Doctrine entity., (*2)

Here is a summary of what you will have to do:, (*3)

Step 1: Create a simple Doctrine entity

<?php
// File: src/DevPro/adminBundle/Entity/Meatup.php

namespace DevPro\adminBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 */
class Meatup
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="string")
     */
    private $title;

    /**
     * @ORM\Column(type="text")
     */
    private $content;

    ...
}

The example above is a very basic Doctrine entity. If you don't understand everything in there, you can find more information in the Doctrine documentation., (*4)

Now you can use a Doctrine command to create the getter and setter methods for you:, (*5)

$ php app/console doctrine:generate:entities DevProadminBundle:Meatup

Now the entity class is complete and you can create the table in the database:, (*6)

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

Step 2: Execute the MeatUp command

Now everything is ready for the MeatUp command to generate your CRUD controller with the the fully qualified class name as argument:, (*7)

$ php app/console ip:meat-up "DevPro\adminBundle\Entity\Meatup"

After the command has successfully finished you can start your web server and check out the controller. If you don't know how you can start the built-in Web-Server have a look at the Symfony documentation., (*8)

If your Web-server is running as localhost:8000 just enter the following URL in your browser:, (*9)

http://localhost:8000/admin/meatup

You can now go on and create a new record by clicking on the button with the label 'Neuer Eintrag'. After creating the new record you will be redirected to the overview page. There you will see that there is a new record and that you can edit it with a click on the button 'Bearbeiten', but there is no column yet to indicate which record it is., (*10)

Step 3: Add OnIndex annotation

Because there is no way for the MeatUp command to guess which properties of your entities you want to show on the overview page, you need to add the OnIndex annotation to tell the bundle that this property should be on it. Luckily we only need to add two lines to the entity above to do that., (*11)

First we need to import the MeatUp namespace and add an alias to it:, (*12)

...
use Doctrine\ORM\Mapping as ORM;
use Ip\MeatUp\Mapping as MU;
...

Now we add the OnIndex annotation to the title property:, (*13)

...
    /**
    * @ORM\Column(type="string")
    * @MU\OnIndexPage
    */
    private $title;
...

That's it! Now we execute the MeatUp command once more and after reloading the website the title will be shown on the overview page with the record we created before:, (*14)

$ php app/console ip:meat-up "DevPro\adminBundle\Entity\Meatup"

You now know already how to use the MeatUp command to create simple CRUD controllers. For more advanced usages please refer to the docs., (*15)

Usage

For the full usage documentation see:, (*16)

Resources/doc/index.md, (*17)

Requirements

License

See the bundled LICENSE file., (*18)

The Versions

26/07 2017

dev-master

9999999-dev

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner

26/07 2017

v0.6.0

0.6.0.0

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner

06/07 2017

v0.5.0

0.5.0.0

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner

17/05 2017

v0.4.2

0.4.2.0

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner

16/05 2017

v0.4.1

0.4.1.0

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner

16/05 2017

v0.4.0

0.4.0.0

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner

05/05 2017

v0.3.0

0.3.0.0

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner

25/04 2017

0.2.0

0.2.0.0

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner

22/04 2017

0.1.0

0.1.0.0

Code generator for Symfony2

  Sources   Download

MIT

The Requires

 

The Development Requires

by Daniel Lehrner