Skip to content

NFR : Generate entity with CLI #330

@lcetinsoy

Description

@lcetinsoy

Currently the only way to generate model is by setting the sql database structure (by raw sql, phpmyadmin, etc) and running phalcon model. However it is error prone, neither convienent nor fast. A more efficient tool would allow to generate the php class and updating the schema based on the class metatada so that sql database is updated for you.

It would works like that :

$ phalcon create-model --name=myName
new attribute name:
$firstName
type:
$string
length(255):
$44
new attribute name:
etc.

This feature exists in sf2 cli. It is based on doctrine2 cli tools. If I am not wrong, sf2 process works as follow : the command line update the meta data then generates the php class based on that.

A first implementation could be done by integrating the sf2 part in charge of updating the database schema and then generates the class using phalcon model.

The next step would be to mimic the sf2 approach by defining the schema in the php class and updating schema based on metadata in the class. Updating entities would be done in a single step and a single file. Besides, deployment would be eased by requiring only to run phalcon database:update on the server after file upload.

I will try to do so tests and see if sf2 tool parts can be easily integrated with phalcon ones.

I think that cli tools is an important part for the adoption of a framework and must let the dev concentrate on dev by abstracting away administration as much as possible.

Kind regards.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions