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

[Solved] Performance

Just curious, will have more than 10 Modules affect performance on the app?

I'm currently having a debate on whether to load modules and take care of loading namespace there or loading via global namespace.

Via modules:

<?php
$app->registerModules([
    'foo' => [...],
    'bar' => [...],
    'baz' => [...],
    'qux' => [...],
]);

Via namespace:

<?php
$loader->registerNamespaces([
    'App\Controller' => '/path/to/app/controller/',
    'App\Model'      => '/path/to/app/model/',
    'Foo\Controller' => '/path/to/foo/controller/',
    'Foo\Model'      => '/path/to/foo/model/',
    'Bar\Controller' => '/path/to/bar/controller/',
    'Bar\Model'      => '/path/to/bar/controller/',
    '....'           => '/you/get/the/point/'
]);

What do you say ?



8.1k
Accepted
answer
edited Mar '14

If you have structure like :

Acme
|______Foo (module)
|______Bar (module)
....
|______Any (module)

you can use one global namespace

$loader->registerNamespaces([
    'Acme' => '/path/to/Acme/'
]);

Phalcon support PSR-0

Well, that was embarrassing! Thank you Oleg.