Creating an Application and API with ‘silex-skeleton-app’

posted in: Silex, Standards | 1

For the UI Application to work, you need to purchase xCRUD http://xcrud.com/

The starter project repo is here – https://github.com/thinkadoo/silex-skeleton-app

Clone the project.

$ git clone
$ composer update

from the root of your project

Then you are ready to generate some code:

php app/console generate:appbundle User user_name:string user_surname:string --migration    
php app/console generate:appbundle Location loc_name:string premises:string —migration
php app/console generate:appbundle Bank bank_name:string surname:string premises:integer amount:integer --migration

Check your Unit Tests

./vendor/bin/phpunit -c app/

Go to /src/Bank/BankBundle/Core/ControllerCore.php
Add relations to ‘premises’ and ‘user’ tables

$xcrud->relation('premises','property','id','name');
$xcrud->relation('name','user','id','name');
$xcrud->relation('surname','user','id','surname');

So it should look like this:

        /**
         * crud
         */
        $controller->get("/crud", function() use ($app, $targetRepository) {
            $xcrud = $app['xcrud'];
            $xcrud->table('bank');
            $xcrud->relation('premises','property','id','name');
            $xcrud->relation('name','user','id','name');
            $xcrud->relation('surname','user','id','surname');
            return $app['twig']->render('xcrud.twig', array(
                'xcrud' => $xcrud,
                'className' => $this->repository
            ));
        });

If you want some test data for the unit tests or just to play with, re-use/re-run your last generator command with –sql it will create a SQL script for the entities you scaffolded.
Install your generated Database from /db/db.sql

Now you should also see the drop down navigation working with the ‘bundle’ or ‘module’ names listed.

http://localhost:8888/silex-skeleton-app/web/index.php/user/crud

Screen Shot 2014-03-13 at 3.25.01 PM

http://localhost:8888/silex-skeleton-app/web/index.php/property/crud

Screen Shot 2014-03-13 at 3.25.18 PM

http://localhost:8888/silex-skeleton-app/web/index.php/bank/crud

Screen Shot 2014-03-13 at 3.25.31 PM

One Response

Leave a Reply