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 connect composer-projects in phalcon autoload?

Hey everyone, it's me again :)

How i can connect anyone project with composer vendor/autoload?

For example: https://github.com/cmfcmf/OpenWeatherMap-PHP-Api

how injected it in phalcon? (namespaces, autoload, etc)


You can use something like this

protected function autoLoader()
  $loader =new Loader();

  // Load composer vendor stuff
  $loader->registerFiles([ BASE_PATH . "/vendor/autoload.php" ]);

  // Register namespaces
    'Models'      => BASE_PATH . '/app/models',
    'Backend'     => BASE_PATH . '/backend',
    'Modules'     => BASE_PATH . '/backend/modules',
    'Plugins'     => BASE_PATH . '/app/plugins',
    'Controllers' => BASE_PATH . '/app/controllers',

  // Register classes

I don't bother integrating it. In my bootstrap.php file, I just call the autoloader itself - that does the setup work.