Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Cabbit

macrumors 68020
Original poster
Jan 30, 2006
2,128
1
Scotland
Hey folks for my most wonderful Cabbit php framework i would like to create something like the rails script/generate scaffold command that is used in the terminal.

Now I am unsure of how complex this is or what software one would use to create such a command so i am looking for some pointers in the right direction.

My aim in the end would be that with a terminal command i can generate php files based on parameters.

For example

scaffold Post tile:string body:text

would create a model called posts, a cabbit_controller and 4 view files(CRUD).

So if anyone has some wee pointers to get me started it would be most welcome for now i am going to put it down to fairies and goblins.
 
Well i took a wee nose round the bundled script generate that comes with rails and so far i have found its a Unix Executable File.
So i am going to have a little nose in these files, i mind back in college learning about batch files so i am thinking these are the unix versions.

Code:
#!/usr/bin/env ruby
require File.expand_path('../../config/boot',  __FILE__)
require 'commands/generate'
 
Why not just use Rails?

Actually, why would you ever use PHP for something other than lowering your self-esteem?

By the way, that script/generate file isn't a shell script, it's a Ruby script that imports the commands/generate Ruby file. The actual generate code imports the arguments you give it to create the requested scaffold.
 
Well i do use Rails but it is not the only language out there and this is a project to create a MVC framework using PHP that mimics some of the interesting Ruby on Rails features.

Its the bases of my honours year thesis and my personal hobby, now i could start writing my own Ruby framework but my lectures don't know what the heck that is.

Now if it ties closely into Ruby for the script generate command then i'll be looking at how Zend accomplishes the same task.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.