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

Beginner Questions

Hey,

its my first time to work with a framework. I have a lot of questions because some things which are shown in the documentation dont working for me. I don't know why.

  1. If i coding in the Model-View-Controller Concept i don't know how the Controller can work in the view. For Example i have a Form which i created with the components of the framework. And i want to get the data which a user sending over the Form. If i intializize the form in the Controller as Function in a Class i get everytimes a error which says, Error: there is no output in ..... I cant understand it. If i creating the form without a framework it works all fine. But if i make this so, i get everytime an Error.

  2. If i coding in the MVC-Concept the controller must invoke the view-data ? Than in the view data (the view datas are in .volt-format) i must execute 1 function. And in this 1 Function are all needing functions for the action. Or I only execute 2 includes. Like :

if($order->buy()){ include("bought.volt"); } else if($order->left()){ include("left.volt") }

  1. I have seen this function which invoke in the controller index the Action index. $this->tag->form("frontend/index");

If i execute a code which display a form. I cant sending the form. The text which i fill in the fields stay everytime in the fields.

  1. How i can execute the Controller in the volt-datas which display the view ? First i must include all needing scripts in this voltscript. Becaue if i execute it without this the server don't know the functions.

  2. I don't understand the routing. For example this code:

$router->add( '/admin/:controller/:action/:params', array( 'namespace' => 'Application\Controllers\Backend', 'controller' => 1, 'action' => 2, 'params' => 3, ) );

What have the namespace for a mind? What are saying the numbes 1-3?

PS: English isnt my mainlanguage. So some sentences can hear a little bit crazy

Conner97

if($order->buy()){ include("bought.volt"); } else if($order->left()){ include("left.volt") }

This line is heinous, you should first start with browsing the INVO and Vokuro examples.

Volt cannot be included by PHP, it first has to be parsed and interpolated by the Volt template engine.

Rule fo thumb:

Controllers fetch data from orm/api/etc, transforms it according to businesss logic, then passes it on to the view component where you can access them as varaiables.