<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

spl_autoload_register(function ($name) 
{
    try{
            //echo $name."</br>";
            //echo getcwd()."</br>";
            $inCurrentClasses=$name.".php";
            if(file_exists ( $inCurrentClasses ))require_once $inCurrentClasses; 
            //echo $inCurrentClasses."</br>";

            $inCurrentModule="classses".DIRECTORY_SEPARATOR.$name.".php";
            if(file_exists ( $inCurrentModule ))require_once $inCurrentModule; 
            //echo $inCurrentModule."</br>";
            
            $inOtherModule="..".DIRECTORY_SEPARATOR.str_replace("\\",DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR,$name).".php"; 
            if(file_exists ( $inOtherModule )) require_once $inOtherModule; 
            //echo $inOtherModule."</br>";

            $inOtherModuleClasses="..".DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR.str_replace("\\",DIRECTORY_SEPARATOR."classes".DIRECTORY_SEPARATOR,$name).".php"; 
            if(file_exists ( $inOtherModuleClasses )) require_once $inOtherModuleClasses; 
            //echo $inOtherModuleClasses."</br>";

        } catch(Exception $e)
        {
            throw new MissingException("Unable to load class $name.",$e);
        }
});

function contains($needle, $haystack)
{
    return strpos($haystack, $needle) !== false;
}