php - Disable autoloader from trying to load JsonSerializable -
php - Disable autoloader from trying to load JsonSerializable -
i have next setup in library within codeigniter:
class datamodelautoloader { public function __construct() { spl_autoload_register(array($this, 'loader')); log_message('debug', 'qr-invited autoloader initialized'); } public function loader($classname) { log_message("debug", "accessing loader class: " . $classname); if (substr($classname, 0, 9) == 'datamodel') { $fullyqualifiedpath = apppath.str_replace('\\', directory_separator, $classname).'.php'; log_message('debug', 'fully qualified path is: ' . $fullyqualifiedpath); require apppath.str_replace('\\', directory_separator, $classname).'.php'; } } }
now, 1 of info models, invite
, in datamodel/invite.php
getting loaded, it's defined as:
class invite implements jsonserializable { ... };
the problem is trying load datamodel/jsonserializable.php
, which, of course, doesn't exist, because want utilize built-in php 5.4.0 jsonserializable
. (i have php 5.5.x installed on box i'm running on). so, i'm getting next exception when run code:
<p>severity: warning</p> <p>message: require(qrinvited-application/datamodel/jsonserializable.php): failed open stream: no such file or directory</p> <p>filename: libraries/datamodelautoloader.php</p> <p>line number: 20</p>
is there way disable attempted autoloading things should built-in php5? or, perhaps i'm doing wrong in how i'm extending class?
if 'namespaces' utilize implements \jsonserializable
. \
makes php knows utilize default
namespace instead of namespace class resides within (in case, datamodel
).
php codeigniter-2
Comments
Post a Comment