English 中文(简体)
new Zend_Loader_Autoloader not finding files
原标题:

I just upgraded from ZF 1.7 to ZF 1.9, and almost everything works fine... except for Autoloader.

Old:

require_once( Zend/Loader.php );  
Zend_Loader::registerAutoload();

New:

require_once  Zend/Loader/Autoloader.php ;  
$loader = Zend_Loader_Autoloader::getInstance();  
$loader->registerNamespace( MySiteName_ );
$loader->setFallbackAutoloader(true);

The files I need to auto-load are mostly not namespaced (because it s a large project from pre-namespacing). They are in the following directories:

  • /application/controllers
  • /common/models
  • /library
  • /vendor

The site seems to work fine EXCEPT that it can t find /library/Form.php
It used to be able to, but not anymore. It works if I add a require_once library/Form.php , but that shouldn t be necessary, and I m worried that if I start doing that in some places, I ll need to abandon the autoloader and hard-code all includes. I thought adding "setFallbackAutoloader(true)", combined with having "library" in my include path would fix it, but it didn t.

My include path is:
.:/Users/lofye/Documents/htdocs/mysitename/vendor
:/Users/lofye/Documents/htdocs/mysitename/common
:/Users/lofye/Documents/htdocs/mysitename/common/models
:/Users/lofye/Documents/htdocs/mysitename/library
:/Users/lofye/Documents/htdocs/mysitename

Any help greatly appreciated!

最佳回答

You said it works if you do this:

require_once  library/Form.php ;

But, if your library path is included, then you should be specifying, as autoloader does, like this:

require_once  Form.php ;

Try typing require_once Form.php ; into your script. Does it bomb? Then, your include path doesn t have /library, and that would need to be fixed.

问题回答

Your autoloader is only going to attempt loading classes that begin with MySiteName_. Try adding Form as a namespace maybe?

$loader->registerNamespace( Form );

The class name inside the file library/Form.php should be Form. What s your class name?

I tested here and is working fine.





相关问题
PHP include_once not working for file in parent directory

I just started working on a site that has been passed down to me that isn t working. I ve found that there s a problem when in /admin/index.php it tries to instantiate an instance of /classes/admin....

How does include path resolution work in require_once?

I was writing an web app in PHP, when I encountered a strange situation. To illustrate my problem, consider a web app of this structure: / index.php f1/ f1.php f2/ f2.php ...

Proper way to set PHP include path for *Nix and Windows

Is this the proper way to define an include path for both *nix and Windows? define( INCPATH , realpath( dirname( __FILE__ ) ) . / ); Note the trailing forward-slash I included above. Is the ...

Symfony Fails opening my sfDoctrineDatabase.class.php

My problem is very simple, yet I feel lost while looking at it ... I am currently working on a Symfony project located on an SVN repository. It has worked well all day but suddenly it crashed... Now ...

Fatal error: Class Zend_Controller_Action not found

I ve found some answers that are closely related to this problem, but I still can t get it resolved. I believe folks are saying that something is not correct with my include path, but I ve tried all ...

new Zend_Loader_Autoloader not finding files

I just upgraded from ZF 1.7 to ZF 1.9, and almost everything works fine... except for Autoloader. Old: require_once( Zend/Loader.php ); Zend_Loader::registerAutoload(); New: require_once ...

Adding my custom PHP Library in include_path

I want to add my PHP library file to be included in include_path, so that i can access it from anywhere in my application running on that server. I tried adding it as per the syntax for include_path ...

php relative and absolute paths

I have read that when including a php file that using absolute paths has a faster processing time than relative paths. What would you suggest to use? include("includes/myscript.php"); or include("/...

热门标签