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

How Phalcon design pattern works?

Hello All, I am recently start working on Phalcon. It is very good framework. I am trying to understand the design pattern of this. Suppose that i am working on Form module. There is a class named Text and i am using this as $text = new Text("field_name");, Text class in included from use Phalcon\Forms\Element\Text;. Now i cheked this namespace directory and found the Text class but there are only a render function. Here it is-

namespace Phalcon\Forms\Element;

/**
 * Phalcon\Forms\Element\Text
 *
 * Component INPUT[type=text] for forms
 */
class Text extends \Phalcon\Forms\Element
{

    /**
     * Renders the element widget
     *
     * @param array $attributes
     * @return string
     */
    public function render($attributes = null) {}

}

Nothing is here for create a form element so i checked the parent class of Text but also this is inherited by an interface and its only define the all fucntions which present in its parent interface. There are no defication for create a form elemet. Then how it's works? How it can produce the code for an form element. I also find such things in another module also. Please explain, is this any design pattern in oops? I also works in npm and also checked packages they also have same design pattern.

Hi semi Phalcon is writed in Zephir to generate an php extension. If you look at the source code in php the ide stubs you will see that all the functions are empty since they only serve to help and autocomplete functions in IDE's. I recommend you to see the source code of Phalcon, although it is written in Zephir, it is very similar to PHP and you will not have any inconvenience to follow it. Text form element source code

Good luck

The design patterns that you have discussed about seems to be nice and may be they can be used by several people just as the design concepts that a lot of people use by creating free logo designs which include the making of clan logo and similarly the making of logos related to any other category.