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

multi module without application

Hi,

Just a little question, Is it possible to run an application with More than one module without using Phalcon\Mvc\Application? I think i need Application because of the function registerModules() but maybe there is an Option to do this on my own?

And if this is possible, is it possible to leave out the module.php for each module and set the two functions registerServices and registerAutoloader as anonymous functions in the index.php with parameters so the module.php is not longer needed?

(Sorry for Bad english ;) )

HeikoManfrass,

Yes, you can run the application without Phalcon\Mvc\Application, but you lack the view component.

Here is a more in depth overview of manually bootstrapping Phalcon: https://docs.phalcon.io/en/latest/reference/applications.html#manual-bootstraping

Yes i tried to use manual bootstrapping, but i can't find a chance to load more then one module without the function registerModules() from die Phalcon\Mvc\Application Object.



98.9k

why don't you want to use registerModules?

Hi, i think i didn't explain my problem well ;)

i don't want to use the Phalcon\Mvc\Application, i want to use manual bootstrapping

but i think the only chance to use registerModules (because i want to have more then one module) is to use Phalcon\Mvc\Application

my question is how to use registerModules or something similar without Application ;)



98.9k

You need to get the processed module from the router:

$module = $router->getModuleName();

You can use this variable to find modules in your own module bag or perform custom validations/instantiations. This basically what Phalcon\Mvc\Application does.

ok thanks :) i'm going to try this :)

small question at the end, is there any php-code to represent what the framework does? similar to the c-code behind the extension?

I mean as if the framework would have been written in php? i think it's easier to understand what to do if someone want to bypass the framework functionality and do it on hiw own?



98.9k

We're creating a new language called Zephir to allow developers to understand how the framework works. https://blog.phalcon.io/post/57161129440/phalcon-2-0-the-future