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

Autoloader does not work in Travis CI

Hey guys,

We are currently integrating our project with travis-ci but stumped upon the problem that the autoloader does not want to work for some reason. We have the current travis file:

language: php
php:
  - 5.3
  - 5.4

services:
  - memcached

before_install:
 - phpenv config-add tests/memcache.ini

before_script:
 - git clone -q https://github.com/phalcon/cphalcon.git
 - (cd cphalcon/build/32bits; export CFLAGS="-g3 -O1 -fno-delete-null-pointer-checks"; phpize && ./configure --enable-phalcon && make -j2 && sudo make install && phpenv config-add ../../../tests/phalcon.ini)
 - wget https://getcomposer.org/composer.phar
 - php composer.phar install

script: (cd tests; phpunit --debug)

This is our autoloader:

$loader = new \Phalcon\Loader();

/**
 * We're a registering a set of directories taken from the configuration file
 */
$loader->registerDirs(
    array(
        $config->application->controllersDir,
        $config->application->modelsDir
    )
);

/**
 * Register primary namespaces
 */

$loader->registerNamespaces(
    array(
        'PH' =>     $config->application->libraryDir . 'PH',
        'Phalcon' => $config->application->libraryDir . 'Phalcon'
    )
);

$loader->register();

// autoload the dependencies found in composer
include __DIR__ . "/../../vendor/autoload.php";

For some reason, it does not register any namespace, nor can i load classes (in travis CI). Locally and on our ubuntu server everything seems to work fine.

The directories are readable on Travis (i checked).

Is there something we are doing wrong?



98.9k

Check the framework's tests that run on Travis, maybe they could help you: https://github.com/phalcon/cphalcon/blob/master/unit-tests/LoaderTest.php



5.0k
Accepted
answer

Sorry, we already fixed this. The problem was our build command:

- (cd cphalcon/build/32bits; export CFLAGS="-g3 -O1 -fno-delete-null-pointer-checks"; phpize && ./configure --enable-phalcon && make -j2 && sudo make install && phpenv config-add ../../../tests/phalcon.ini)

we changed it to

- (cd cphalcon/build; sudo ./install && phpenv config-add ../../tests/phalcon.ini)

and it worked :)