• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
symfony style admin/backend generator

#1
[eluser]Majd Taby[/eluser]
Hey, I was just thinking, since automatic admin generation is not a feature of CI (for good reason) that it would be cool to build a symfony style backend generator.

Something along the lines of:

1) Uses YAML to setup the structure
2) Generated the db automatically
3) Builds the controllers/models/views necessary
4) Contain built-in authentication

It would probably use modular separation, since that seems fitting...

What do you guys think? any design tips?

#2
[eluser]xwero[/eluser]
I think built-in authentication will not be for everyone because some people prefer their own methods, but none the less it's a great idea.

Can you give an example of the YAML file you have in mind?

#3
[eluser]nmweb[/eluser]
I was considering an idea like that. It's still very much a concept but I'm trying to get my head around it.

#4
[eluser]Crafter[/eluser]
Well, at one time I looked at combining PhpDevShell (http://www.phpdevshell.org) with CodeCrafter but didn't find the time to complete this.

It should be possible to plug the phpdevshell files into Code Crafter and have code generated for your database.

You'd probab;y need to find a YAML database creator. There are plenty of XML based ones.

#5
[eluser]Majd Taby[/eluser]
You know what, I was thinking about it, it really isn't very useful to generate a whole backend for yourself automatically...that kinda goes against the whole philosophy of CI and is the reason I switched from Symfony to CI in the first place.

What I've been doing was create standalone libraries...so far i created one for simple, one level userauth, and another for formgeneration.

For form generation, here's the basic layout:

In you controller:

Code:
function edit(){
        $this->jtabyforms->initiate($this->spyc->YAMLLOAD('definitions/portal_form.yml'));
        $id = $this->uri->segment(3);
        echo $this->jtabyforms->getHTML();
    }

Then in the portal_form.yml config file:

Code:
title:
    class: TextBox
    label: Title
    attributes:
    value: Enter title here
date:
    class: TextBox
    label: Title
    attributes:
    value:
entry:
    class: TextArea
    label: Entry
    attributes:
        cols: 45
        rows: 10
    value:

The output of that code is:

Code:
<label for="title">
                Title
            </label>
            &lt;input type="text" value="Enter title here" name="title" /&gt;
        
            <label for="date">
                Title
            </label>
            &lt;input type="text" value="" name="date" /&gt;
        
            <label for="entry">

                Entry
            </label>
            &lt;textarea cols="45"rows="10"&gt;
                
            &lt;/textarea&gt;

#6
[eluser]Crafter[/eluser]
Quote:You know what, I was thinking about it, it really isn’t very useful to generate a whole backend for yourself automatically...that kinda goes against the whole philosophy of CI and is the reason I switched from Symfony to CI in the first place.

I think sometimes we miss the point as to why we are programmers. Sure, I enjoy programming as much as you do. But really, the idea that any kind of code generation is contrary to coding practice really doesn't make sense to me.

You talk about "the whole philosophy of CI". Well, CI simplifies mundane, repititive and predictable tasks easy by providing libraries and structure to your code. If you really want a do it yourself solution, code your solution in machine code Wink .

To me, it makes sense to use code generation. It gives me more time to concentrate on business solutions, and providing business solutions is what being a programmer is all about.

#7
[eluser]Majd Taby[/eluser]
sorry if this post comes off as a bit aggressive, that's not the point, really.

To start off with, in my opinion being a programmer is not about "providing business solutions" at all. To me, being a programmer is about doing something you love, making your life and other's lives easier, and to write software..."providing business solutions" is for a consultant...not a programmer. In fact, having a website generated in seconds totally defeats the purpose of a programmer. The more code generation there is, the harder it is to modify, the most compromises you have to make, or your client has to make, in order not to break the very rigid generation algorithm.

To make a code generation script flexible, it has to be very complex, at which point it becomes easier to just use a framework like CI to do the job.

The reason I love CI is that it has "a small footprint" and that it doesn't strictly tell me how to write my code, it helps me achieve proper structure.


But then again, different strokes for different folks

#8
[eluser]Crafter[/eluser]
No agression sent or felt here in this forum. I'm loving this topic!

#9
[eluser]Crafter[/eluser]
Sorry, trigger happy there.

Zaatar, just where do we draw the line. I see your arguement about taking the fun out of the coding process, but how different is using generated code against say cutting and pasting code into yiur application, or using a library to do things.

Many years,ago I programmed on the VOS operating system where we had to hand program our database access. For example, we had indexed files, and doing an indexed read meant you read the index, get the record position in the data portion, then read the record from the file. Today I use a "SELECT ... WHERE ..." from a database. I chose not to continue using the file based database library because SQL provided me much flexibility.

When I first learnt HTML, I hand coded. Today, I use generated HTML code for most of my displays/views and customise them using code.

Quote:The more code generation there is, the harder it is to modify, the most compromises you have to make, or your client has to make, in order not to break the very rigid generation algorithm.
Cannot agree more with you. I'm not saying program your application based on generated code. That would be foolish. But I say use automation where ever you can. The time saved frees you up to provide more value to the end user by building on existing code..

Quote:To me, being a programmer is about doing something you love, making your life and other’s lives easier, and to write software..."providing business solutions” is for a consultant...not a programmer.

I want to urge you to rethink this position. I've been programming for over 17 years (20+ if you count student years) and I love it. Right now it's almost 2 am at home and I'm taking a break from ...coding ...!!!

However, I've learnt in those years that to continue enjoy what you do, you must be able to see the satisfaction in the faces of those who reap your labour, and that is whant I was referring to when I spoke about providing solutions. Your users dont see a bunch of code, they see a tool to help them with their budget, to keep records and save time.

Have a look at this tongue-in-cheek article;
http://www.codinghorror.com/blog/archives/000962.html

#10
[eluser]lifewithryan[/eluser]
I've written a script to do the mundane code generation for me and would love to have someone else give it a run. I don't include any of the non-essential stuff nor make assumptions about the application. Meaning: I don't do the authentication stuff, that is up to the developer, nor do i assume they want all this AJAX/Javascript stuff...

It simply creates the SQL, Model, View and Controller files necessary to get an app off the ground. There's no major styling either, again that is up to the designer/developer. But it does help you get into the meat of your application more quickly.

If anyone wants to take a look, let me know. I plan to have a sub-domain up where I'll be hosting the scripts/info sometime tonight if possible: http://ignition.lifewithryan.com (I've called it "Ignition").

I designed intentionally to be simple and get out of your way. Again, I make no assumptions about the purpose of the app being generated and leave things style, AJAX, Javascript enhancement, etc up to the developer. Simply create a template file for your object that the ignite script will read and start generating. The only extraneous piece I include is a very simple, and boring css file that can (and should be) completely overwritten by the developer.

Let me know if anyone is interested....


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.