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

Undocumented feature for model generation with single name

I like to name my models with a singular name, e.g. Animal instead of Animals and so on, but the dev tools seems to use the table name by default, so if you use a plural table name, then you have plural model names.

I've found completely by accident that if you pass a name and a --name value, you can achieve this:

phalcon model Animal --name=animals

This will create a model called Animal using the table of animals. Maybe this will help someone else!

Unfortunately this doesn't work with all-models



5.1k

Not easy to solve it and we have interest to name tables and class in English, in French plural of Animal is Animaux !! ;-)

in your model Animal you have this function ?


    public function getSource()
    {
        return 'Animals';
    }

@phill67000 The dev tools automatically creates the getsource method as well as setting all the properties.