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

Autoload seems to fail on production

Hey, I have a MAMP server running on my Mac with PHP 5.3.28 , My Production runs 5.5.16.

Both run Phalcon 1.3.2.

I have a file called "uuid.php" in my "app/plugins" folder, And also in "loader.php", I've added

$loader->registerDirs(
    array(
        $config->application->controllersDir,
        $config->application->modelsDir,
        $config->application->pluginsDir
    )
)->register();

This works well on development and autoloads my uuid.php file, but when moved to production I get an error message saying the class UUID doesn't exist, and this is solved only when I manually include the file in the specific class:

include_once $config->application->pluginsDir . 'uuid.php';

I'm not sure what's the huge difference between dev/prod or if I'm missing anything. Would love some insights / tips.

Thanks, Shai :)

Is your production server Linux? If so, it's probably a case-sensitivity problem. I had the job of developing on Windows and then going live on Linux and everything went to hell because Phalcon capitalized something that should've been lowercase. I've since added a hard reference to that particular foldername and it works beautifully now.

Going from your example and my own experience, I almost want to bet Phalcon's trying load Uuid.php instead of uuid.php.

My production is Centos ... But also my dev is Mac OS , meaning that's less likely. How can I check exactly what the autoloader tried to fetch ? ...

I never use Macs but maybe they have some sort of fallback for case-insensitivity for when they don't directly find a file?

Anyway, this is more useful to you I hope. I used this bit of code to find out the full path of the file it tries to load.

$eventsManager = new \Phalcon\Events\Manager();
$loader = new Loader();
//Debugging stuff for linux paths, case sensitive buggers
//Listen all the loader events
$eventsManager->attach('loader', function($event, $loader) {
    if ($event->getType() == 'beforeCheckPath') {
        echo $loader->getCheckedPath().'<br />';
        die;
    }
    if($event->getType() == 'afterCheckPath') {
        echo('path not found');
        die;
    }
});
$loader->setEventsManager($eventsManager);