We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.