Re: include path sub dirs and php.ini

From: Date: Wed, 03 Jan 2001 20:30:52 +0000
Subject: Re: include path sub dirs and php.ini
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32545@lists.php.net to get a copy of this message
You can have something like this (untested) in an autoprepend file: function add_to_path_recursive( $dir ) { $sep = ( false === strpos( strtolower( PHP_OS ) , 'win' ) ) ? ':' : ';' ; clearstatcache() ; if( '/' == substr( $dir , -1 ) || '\\' == substr( $dir , -1 ) ) { $dir = substr( $dir , 0 , -1 ) ; } $h = opendir( $dir ) ; while( $f = readdir( $h ) ) { if( '.' != $f && '..' != $f && is_dir( "$dir/$f" ) ) { ini_set( 'include_path' , realpath( "$dir/$f" ) . $sep . ini_get( 'include_path' ) ) ; add_to_path_recursive( "$dir/$f" ) ; } } closedir( $h ) ; } At 20:46 3.1. 2001, Matt McClanahan wrote the following: -------------------------------------------------------------- >On Wed, 3 Jan 2001, Lewis Bergman wrote: > >> I apologize if this gis a second post but I goat an error back. >> >> I would like to include the entire PEAR tree in the php.ini include_path >> variable. I cannot seem to make this work however. PEAR is laid out like this: >> /usr/local/lib/php >> | >> |-DB--------- >> |-HTTP |-mysql.php >> |-etc... |-pgsql.php >> >> and so on. I am trying to avoid putting all the PEAR directories into the >> include_path. IS there a way to include the top level dir and recurse down? > >If you specify a relative path in your include/require calls, the >include_path will be searched for that relative path. So the only path >you need in your include_path to have Pear accessible is the parent >directory. > >That is, if your include_path includes /usr/local/lib/php.. > >include 'DB/mysql.php'; > >will find /usr/local/lib/php/DB/mysql.php. This is highly prefereable to >including all Pear directories in the include_path. > >Matt > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net ------end of quote------ ____________________________________________________________ Cynic: A member of a group of ancient Greek philosophers who taught that virtue constitutes happiness and that self control is the essential part of virtue. cynic@mail.cz

« previous php.general (#32545) next »