Hey there,

I've been strugling with this for over a few days now, i am working on a new framework, but my main issue with this is that it has to be able to contain itself through reflections and captures, for example, when an class is called abstract or an instance has to be made from a class this package just calls the right class for it, but my application does not use any require_once or include_once except for interfaces, so we all know that __autoload solves this problem if you know where the file you need is, if not, i wanted my application to search for it, with no matches it would throw an exception and will inform the user that this class does not exists in the project's tree scope.

But the problem was the fact that i was not able to do an actual search from a path up to it's last director, i tried a traversable directory reader, but it just didn't fit my needs, so i did found a solution to read out an entire tree of directories and search on the found results.

PHP Code:
function __autoload($classNamespace){
        
$dir = new RecursiveIteratorIterator(new RecursiveDirIterator('./'), true);
        foreach ( 
$dir as $file ) {
            echo 
str_repeat("--"$dir->getDepth()) . $file\n<br>";
        } 
        echo 
"Unable to include/require : $classNamespace";
        exit(
0);
    }
    
    class 
DirIterator implements Iterator {
    
        protected 
$dir;
        
        protected 
$key;
        protected 
$file;
        protected 
$valid;
            
        public function 
__construct($path) {
            
$this->dir opendir($path);
        }
        
        public function 
__destruct() { 
            
closedir($this->dir);        
        }
        
        public function 
rewind() {
            
$this->key 0;
            
rewinddir($this->dir);
            
$this->next();
        }
        
        public function 
next() {
            
$this->key++;
            
$this->valid false !== ($this->file readdir($this->dir));
        }
        
        public function 
key() {
            return 
$this->key;
        }
        
        public function 
current() {
            return 
$this->file;
        }
        
        public function 
valid() {
            return 
$this->valid;
        }
    
    }
    
    class 
RecursiveDirIterator extends DirIterator implements RecursiveIterator {
    
        protected 
$path;
        
        public function 
__construct($path) {
            
parent::__construct($path);
            
$this->path $path;
        }
        
        public function 
hasChildren() {
            return ( 
is_dir($this->path '/' $this->file) &&
                    !(
$this->file == '.' || $this->file == '..'));        
        }
        
        public function 
getChildren() {
            return new 
RecursiveDirIterator($this->path '/'$this->file);
        }
    } 
This thread is pure ment for people looking for a same sort solution, you can now itterate through every level of your tree without braking it and without working with chDir();

I got this solution from the link below, read it .... it's extremely handy :-)
http://www.ramikayyali.com/archives/...2/25/iterators

Hope this is usefull for some of us...
Cheers,
Galo