Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a code generation package #24

Open
WanWizard opened this issue Mar 8, 2013 · 4 comments
Open

Create a code generation package #24

WanWizard opened this issue Mar 8, 2013 · 4 comments

Comments

@WanWizard
Copy link
Contributor

This package will contain the code generation (scaffolding) code of the 1.x Oil package.

It should have a pluggable architecture, so that external components can add extra features to it. For example the ORM package could provide the generators for ORM models.

@knitinr
Copy link

knitinr commented Mar 11, 2013

I've been thinking of a rough design of how Oil ought to work, with some means of templating the generated code. Let's say we have an OilMain class that is invoked via a PHP-CLI and loads its config. It can then create an instance of the command class (we would have a class for generte, refine etc.), set the parameters and call execute(). For generate, specifically, we can have a DbSchema class that fetches the database schema using a helper for each DB, possibly using the query builder. With the schema, the GenerateCommand object can then make a call to the template engine by setting the data and calling render() on it.

---BEGIN illustration

OilMain

Command (GenerateCommand, ...)
+Parameters
+Execute

DbSchema
+FetchTableProperties (table name, col specs, pks, fks, ixs, other constraints)

TemplateEngine
+setData
+render

---END illustration

I've been toying with the idea of using something like Smarty as a template engine, though that would need some more investigation on my part. Also, if we choose to make oil function independently of Fuel, our DB queries can be generated by the helpers rather than through the query builder. Perhaps we can abstract it out later to get Fuel to use it, if needed, as it is a subset of the functionality of Fuel's query builder.

@emlynwest
Copy link
Contributor

Looks like a good start but it seems like you are focusing too much on the tasks themselves rather than oil itself. The first step needs to be being able to run specific tasks via a cli. The oil package does not need to be tied to any other fuel package. The tasks themselves can be provided by other fuel packages, so the scaffold creation by the DB or Orm package.

@WanWizard
Copy link
Contributor Author

Something serious needs to be done about the commandline as well. It's rather stupid to try to specify everything you need on a single line, things like

php oil g migration add.to_mail_to_contact_to_users to_mail:varchar[255]

I think it would be a lot better if you could have some sort of interactive shell, in which you could type in commands like
add to_mail_to_contact to users_to_mail varchar(255)
which would the be validated (per line) and stored, until you give some form of commit or go.

@emlynwest
Copy link
Contributor

This would be very nice. It's such a pain to have to enter a massive long string and also allows errors in input to be handled better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants