We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Generate MODELS for all tables at once (without using webtools!)

Hi all,

How can I generate models for all my tables in my db at once WITHOUT using webtools?

It must include:

  • Setters & Getters *
  • Set foreign keys *
  • Define relations *
  • Forced *

Shell example: phalcon model --name ??ALL TABLES in DB?? --get-set --force

Do i need multiple lines in shell for this?

I'm looking forward to your answers :)



13.4k
Accepted
answer

Using DevTools there is the command: phalcon create-all-models

The parameters are:

    protected $_possibleParameters = array(
        'config=s'          => "Configuration file  ",
        'models=s'          => "Models directory ",
        'schema=s'          => "Name of the schema. [optional]",
        'namespace=s'       => "Model's namespace [optional]",
        'extends=s'         => "Models extends [optional]",
        'force'             => "Force script to rewrite all the models.  ",
        'get-set'           => "Attributes will be protected and have setters/getters.  ",
        'doc'               => "Helps to improve code completion on IDEs  ",
        'relations'         => "Possible relations defined according to convention.  ",
        'fk'                => "Define any virtual foreign keys.  ",
        'validations'       => "Define possible domain validation according to conventions.  ",
        'directory=s'       => "Base path on which project will be created",
    );


1.6k

Tnx, that'll do the job!