Welcome Guest, Not a member yet? Register   Sign In
Generating Code Using The CLI
#1

[eluser]Yorick Peterse[/eluser]
First of all, yes, I'm back. Second of all, yes, I'm working on PyroCMS again. Now to get back to my topic, generating code. When I stopped working on PyroCMS (and thus stopped using CI) about 2-3 months ago I started to look at some other scripting languages, such as Python and Ruby. I also looked at frameworks, such as TurboGears and RoR. While I never really tried Ruby (and RoR) the one thing that I did like was the ability to generate controllers/models using the CLI.

Several utilities have been made so far, but none of them actually worked or they are extremely outdated. Because of this I thought it would be nice to create a command line script that would generate controllers/methods based on some very basic input. The idea is still rather vague because I first want to know if there is actually any interest in a tool like this, it's not worth making something if nobody gives a shit is it?

Application Info

The application would be named "ignite", I know it isn't the most original name but atleast it matches the framework's name. Basic usage would be like the following:

Code:
ignite type name

For example, to generate a controller using the name "Cookies_are_awesome" you would do the following:

Code:
ignite controller Cookies_are_awesome

This would generate a basic controller with 4 method: index, create, edit and delete. If you want to specify the methods to create you would do the following:

Code:
ignite controller Cookies_are_awesome -m method_1 method_2 method_3

or

Code:
ignite controller Cookies_are_awesome --methods method_1 method_2 method_3

Generating a model based on a table would be possible by using the following command:

Code:
ignite model Cookies_are_awesome -t my_table

or

Code:
ignite model Cookies_are_awesome --table my_table

Both these commands (which are the same) would generate a model with some basic methods that can access the database.

Possible Parameters

-m Define the names of the methods to generate
-t The table used to generate the model
-h Help information about the script
-l Libraries to load
-h Helpers to load

Final Words

Because I only came up with the idea about an hour ago everything is just an idea, therefore I'd love to have your input!
#2

[eluser]Jeffrey McManus[/eluser]
I'm surprised there isn't something like this already. CakePHP has one.

I would love to see something that has the ability to build models based on an existing database schema. Specify the connection info and run the tool, it figures out where everything is then builds basic CRUD models.
#3

[eluser]jayrulez[/eluser]
Quite a few frameworks provide this through cli, an extension/ a module/ a plugin.
#4

[eluser]Phil Sturgeon[/eluser]
I use Copy and Paste, but whatever works for you!
#5

[eluser]Jaimie[/eluser]
I would die for a ZF/CakePHP like CI CLI app. I love them.

Would be nice if CI had one aswell, so any contributions to it are appriciated!
#6

[eluser]Yorick Peterse[/eluser]
[quote author="Phil Sturgeon" date="1270643304"]I use Copy and Paste, but whatever works for you![/quote]

I normally use the CodeIgniter bundle for TextMate, but it still requires you to create the files yourself.
#7

[eluser]n0xie[/eluser]
It's pretty easy to make. We made a module that basically does this: it generated CRUD baseline Controllers, models and views. If you load it like a module, you have access to everything good that is CI without having to learn another cli tool. Basically start a new project, install HMVC, copy CRUD module, go to http://domain.tld/crud and you're good to go.




Theme © iAndrew 2016 - Forum software by © MyBB