You are viewing a plain text version of this content. The canonical link for it is here.
Posted to zeta-users@incubator.apache.org by Christian Grobmeier <gr...@gmail.com> on 2010/10/07 11:09:57 UTC
[zeta-users] Confusion with classloader
Hello all,
I have my zetacomponents stored at:
lib/zetacomponents/
in this folder is:
lib/zetacomponents/autoload with autoload php files
lib/zetacomponents/Base
lib/zetacomponents/UserInput
Then I added this to my autoload:
$options = new ezcBaseAutoloadOptions;
$options->debug = true;
ezcBase::setOptions( $options );
ezcBase::setWorkingDirectory('lib/zetacomponents');
ezcBase::autoload( $class );
My components look like:
Base/src/*.php
For some reasons classloading works with Base.
But for UserInput i needed to change at line 383 to something like this:
$a = explode( '/', $file, 3 );
if(sizeof($a) == 3) {
$file = $a[0]. '/src/' . $a[1]. "/" . $a[2];
} else {
$file = $a[0]. '/src/' . $a[1];
}
to make this work. This feels strange to me. I guess I have done
something bad with pathes. Or is it a bug in the classloader classes?
Best regards,
Christian
Re: [zeta-users] Confusion with classloader
Posted by Christian Grobmeier <gr...@gmail.com>.
>>> Did you try without calling setWorkingDirectory() ?
>>
>> yes (as above):
>>
> I asked *withOUT* ;)
ups :-) sorry :-)
Yes I have tried before, even with additional repos. But I removed it now
>> ezcBase::setWorkingDirectory('lib/zetacomponents');
>> ezcBase::autoload( $class );
>>
>> Basically yes, just with setWorking Directory and without die.
>>
>
> If that works for you then it's ok, note that you should *NOT* (have
> to) use setWorkingDirectory.
I have removed the method and load with Base and spl_autoload_register.
This works fine and without modifications.
Thanks for your help!
Cheers
Christian
Re: [zeta-users] Confusion with classloader
Posted by James Pic <ja...@gmail.com>.
On Thu, Oct 7, 2010 at 1:28 PM, Christian Grobmeier <gr...@gmail.com> wrote:
> Hi
>
>> Did you try without calling setWorkingDirectory() ?
>
> yes (as above):
>
I asked *withOUT* ;)
> ezcBase::setWorkingDirectory('lib/zetacomponents');
> ezcBase::autoload( $class );
>
> Basically yes, just with setWorking Directory and without die.
>
If that works for you then it's ok, note that you should *NOT* (have
to) use setWorkingDirectory.
Anyway, if you really want to use it then i don't think you need to
call it at each __autoload() call, because setWorkingDirectory() is
the only setter for the static variables it is about.
Regards
James
--
http://jamespic.com/contact
Customer is king - Le client est roi - El cliente es rey.
Re: [zeta-users] Confusion with classloader
Posted by Christian Grobmeier <gr...@gmail.com>.
Hi
> Did you try without calling setWorkingDirectory() ?
yes (as above):
ezcBase::setWorkingDirectory('lib/zetacomponents');
ezcBase::autoload( $class );
> What is your autoload function code? is it:
>
> function __autoload( $class ) {
> ezcBase::autoload( $class ) or die( "Couldn't load $class" );
> }
Basically yes, just with setWorking Directory and without die.
Like
function __autoload( $class ) {
if(substr($class,0,3) == "ezc") {
ezcBase::setWorkingDirectory('lib/zetacomponents');
ezcBase::autoload( $class );
return;
}
// other stuff
}
Re: [zeta-users] Confusion with classloader
Posted by James Pic <ja...@gmail.com>.
Here is a complete example, from setup to working php autoload:
➜ ~ cd src/zeta/
➜ zeta scripts/setup-env.sh
Creating autoload environment for 'trunk':
Autoload directory exists.
Symlink for archive_autoload.php to Archive/src/archive_autoload.php exists.
Symlink for authentication_database_autoload.php to
AuthenticationDatabaseTiein/src/authentication_database_autoload.php
exists.
Symlink for authentication_openid_autoload.php to
AuthenticationDatabaseTiein/src/authentication_openid_autoload.php
exists.
Symlink for authentication_autoload.php to
Authentication/src/authentication_autoload.php exists.
Symlink for base_autoload.php to Base/src/base_autoload.php exists.
Symlink for cache_autoload.php to Cache/src/cache_autoload.php exists.
Symlink for configuration_autoload.php to
Configuration/src/configuration_autoload.php exists.
Symlink for console_autoload.php to
ConsoleTools/src/console_autoload.php exists.
Symlink for db_schema_autoload.php to
DatabaseSchema/src/db_schema_autoload.php exists.
Symlink for db_autoload.php to Database/src/db_autoload.php exists.
Symlink for query_autoload.php to Database/src/query_autoload.php exists.
Symlink for debug_autoload.php to Debug/src/debug_autoload.php exists.
Symlink for document_autoload.php to Document/src/document_autoload.php exists.
Symlink for log_database_autoload.php to
EventLogDatabaseTiein/src/log_database_autoload.php exists.
Symlink for log_autoload.php to EventLog/src/log_autoload.php exists.
Symlink for execution_autoload.php to
Execution/src/execution_autoload.php exists.
Symlink for feed_autoload.php to Feed/src/feed_autoload.php exists.
Symlink for file_autoload.php to File/src/file_autoload.php exists.
Symlink for graph_database_autoload.php to
GraphDatabaseTiein/src/graph_database_autoload.php exists.
Symlink for graph_autoload.php to Graph/src/graph_autoload.php exists.
Symlink for image_analyzer_autoload.php to
ImageAnalysis/src/image_analyzer_autoload.php exists.
Symlink for image_autoload.php to ImageConversion/src/image_autoload.php exists.
Symlink for mail_autoload.php to Mail/src/mail_autoload.php exists.
Symlink for mvc_authentication_autoload.php to
MvcAuthenticationTiein/src/mvc_authentication_autoload.php exists.
Symlink for mvc_feed_autoload.php to
MvcFeedTiein/src/mvc_feed_autoload.php exists.
Symlink for mvc_mail_autoload.php to
MvcMailTiein/src/mvc_mail_autoload.php exists.
Symlink for mvc_template_autoload.php to
MvcTemplateTiein/src/mvc_template_autoload.php exists.
Symlink for mvc_autoload.php to MvcTools/src/mvc_autoload.php exists.
Symlink for persistent_object_autoload.php to
PersistentObjectDatabaseSchemaTiein/src/persistent_object_autoload.php
exists.
Symlink for persistent_autoload.php to
PersistentObject/src/persistent_autoload.php exists.
Symlink for php_generator_autoload.php to
PhpGenerator/src/php_generator_autoload.php exists.
Symlink for reflection_autoload.php to
Reflection/src/reflection_autoload.php exists.
Symlink for search_autoload.php to Search/src/search_autoload.php exists.
Symlink for signal_autoload.php to SignalSlot/src/signal_autoload.php exists.
Symlink for system_autoload.php to
SystemInformation/src/system_autoload.php exists.
Symlink for template_autoload.php to Template/src/template_autoload.php exists.
Symlink for template_translation_autoload.php to
TemplateTranslationTiein/src/template_translation_autoload.php exists.
Symlink for translation_cache_autoload.php to
TranslationCacheTiein/src/translation_cache_autoload.php exists.
Symlink for translation_autoload.php to
Translation/src/translation_autoload.php exists.
Symlink for tree_db_autoload.php to
TreeDatabaseTiein/src/tree_db_autoload.php exists.
Symlink for tree_persistent_autoload.php to
TreePersistentObjectTiein/src/tree_persistent_autoload.php exists.
Symlink for tree_autoload.php to Tree/src/tree_autoload.php exists.
Symlink for test_autoload.php to UnitTest/src/test_autoload.php exists.
Symlink for url_autoload.php to Url/src/url_autoload.php exists.
Symlink for input_autoload.php to UserInput/src/input_autoload.php exists.
Symlink for webdav_autoload.php to Webdav/src/webdav_autoload.php exists.
Symlink for workflow_database_autoload.php to
WorkflowDatabaseTiein/src/workflow_database_autoload.php exists.
Symlink for workflow_event_autoload.php to
WorkflowEventLogTiein/src/workflow_event_autoload.php exists.
Symlink for workflow_signal_autoload.php to
WorkflowSignalSlotTiein/src/workflow_signal_autoload.php exists.
Symlink for workflow_autoload.php to Workflow/src/workflow_autoload.php exists.
/home/jpic/src/zeta
➜ zeta phpsh
Starting php
PHP Warning: Module 'xdebug' already loaded in Unknown on line 0
type 'h' or 'help' to see instructions & features
php> include 'trunk/Base/src/base.php';
php> function __autoload( $class ) {
... ezcBase::autoload( $class ) or die( "Couldn't load $class" );
... }
php> = class_exists( 'ezcMvcRouter' )
true
php>
Hope this helps
Regards
James
--
http://jamespic.com/contact
Customer is king - Le client est roi - El cliente es rey.
Re: [zeta-users] Confusion with classloader
Posted by James Pic <ja...@gmail.com>.
Hi Christian,
On Thu, Oct 7, 2010 at 1:09 PM, Christian Grobmeier <gr...@gmail.com> wrote:
> This feels strange to me. I guess I have done
> something bad with pathes. Or is it a bug in the classloader classes?
Did you try without calling setWorkingDirectory() ?
What is your autoload function code? is it:
function __autoload( $class ) {
ezcBase::autoload( $class ) or die( "Couldn't load $class" );
}
Regards
James
--
http://jamespic.com/contact
Customer is king - Le client est roi - El cliente es rey.
Re: [zeta-users] Confusion with classloader
Posted by Christian Grobmeier <gr...@gmail.com>.
>> Don't use setWorkingDirectory, it's for unit testing only.
>> The only thing you really have to do is:
>>
>> require '/home/derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php';
>> (Adjusting the path).
>
> ok, but i need my own __autoload. Any chance to avoid ezc_bootstrap?
> Including base and try SPL?
Yes, this works - thanks guys
I knew i made it to difficult. :-)
Re: [zeta-users] Confusion with classloader
Posted by Christian Grobmeier <gr...@gmail.com>.
> Don't use setWorkingDirectory, it's for unit testing only.
> The only thing you really have to do is:
>
> require '/home/derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php';
> (Adjusting the path).
ok, but i need my own __autoload. Any chance to avoid ezc_bootstrap?
Including base and try SPL?
Re: [zeta-users] Confusion with classloader
Posted by Derick Rethans <ap...@derickrethans.nl>.
On Thu, 7 Oct 2010, Christian Grobmeier wrote:
> I have my zetacomponents stored at:
> lib/zetacomponents/
>
> in this folder is:
> lib/zetacomponents/autoload with autoload php files
> lib/zetacomponents/Base
> lib/zetacomponents/UserInput
>
> Then I added this to my autoload:
>
> $options = new ezcBaseAutoloadOptions;
> $options->debug = true;
> ezcBase::setOptions( $options );
> ezcBase::setWorkingDirectory('lib/zetacomponents');
Don't use setWorkingDirectory, it's for unit testing only.
The only thing you really have to do is:
require '/home/derick/dev/ezcomponents/trunk/Base/src/ezc_bootstrap.php';
(Adjusting the path).
Derick
--
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug