php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #54032 ability to to handle Class not found error
Submitted: 2011-02-17 00:11 UTC Modified: 2011-12-04 23:19 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:2 of 3 (66.7%)
Same Version:2 (100.0%)
Same OS:0 (0.0%)
From: tyra3l at gmail dot com Assigned: tyrael (profile)
Status: Closed Package: SPL related
PHP Version: 5.3.5 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: tyra3l at gmail dot com
New email:
PHP Version: OS:

 

 [2011-02-17 00:11 UTC] tyra3l at gmail dot com
Description:
------------
currently you can throw an exception from the autoloader, hence if you can't 
find a class, your application can gracefully exists, instead of exiting via the 
class not found fatal error.
my problem is, that I would like to use multiple autoloader (for example in a 
project which uses multiple component, or framework), but in this case, I can't 
throw an Exception from my autoloader, because maybe the other autoloaders could 
load the class.
if I'm sure that I will register the last autoloader, the this isn't a 
problem(my last autoloader will throw the Exception on missing class), but maybe 
I have to load a component late of the exection.
it would be cool, if I could somehow register a callback which will be called, 
when the spl autoload callbacks was executed, but the class couldn't be loaded
of course, from this callback, I cannot continue the normal execution flow, 
however I can log the error, and let the callback return and get the class not 
found fatal error, or throw an Exception, and handle/log the error from a higher 
level.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-17 00:15 UTC] tyra3l at gmail dot com
*exists -> exit
*exection -> execution
* spl autoload callbacks was executed -> spl autoload callbacks was executed 
without finding the class
* I cannot continue the normal execution flow -> I couldn't continue the normal 
execution flow
* from a higher level -> at a higher level

sorry, its getting late, and my english skill degrades with sleep deprivation
 [2011-03-29 09:39 UTC] tyra3l at gmail dot com
after some sleep and a little bit thinking, I think that the best solution would 
be to introduce a new Exception type, which will be thrown if the execution of the 
autoload callbacks doesn't successfully load the class.
what do you think?

Tyrael
 [2011-12-04 23:19 UTC] tyrael@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: tyrael
 [2011-12-04 23:19 UTC] tyrael@php.net
if I can come up with something, I will write an RFC instead.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 17:01:34 2025 UTC