phpspl-autoloader

spl_autoload fault on remote server


Sorry for my bad language :)

On my local apache 2.2 php 5.3.13 all OK, but on remote server (php 5.3 too) spl_autoload throw logic exception:

Fatal error: Uncaught exception 'LogicException' with message 'Class System\Core\Helper\Helper could not be loaded' in /home/u737840143/public_html/index.php:6 Stack trace: #0 /home/u737840143/public_html/index.php(6): spl_autoload('System\Core\Hel...') #1 {main} thrown in /home/u737840143/public_html/index.php on line 6

Code:

<?php

spl_autoload_extensions('.php');
spl_autoload_register();

\System\Core\Helper\Helper::getLanguage();

$router = new \System\Router\Router();
$router->init();

Remote folder structure corresponds to local.


Solution

  • I've found the answer - spl_autoloader() can't work correctly with uppercases in many operating systems, but on Windows it works well. So, after renaming all folders in lowercase (yes, and rewriting namespaces in ALL FILES...) everything started working.

    <?php
    
    spl_autoload_extensions('.php');
    
    spl_autoload_register();
    
    
    try {
    
       \system\core\helper\Helper::getLanguage();
    
       $router = new \system\router\Router();
       $router->init();
    
    } catch (\Exception $e){
       echo $e;
    }