Edit report at http://bugs.php.net/bug.php?id=52406&edit=1

 ID:               52406
 Updated by:       fel...@php.net
 Reported by:      jinmoku at hotmail dot com
 Summary:          spl_autoload support phar with namespace
-Status:           Open
+Status:           To be documented
 Type:             Bug
 Package:          SPL related
 Operating System: XP, OSX
 PHP Version:      5.3.3

 New Comment:

Hi, the spl_autoload() will try to find the 'framework/test.php', i.e.
the lowercased name, so on *nix will fail because it's case-sensitive,
and you are using $phar->addFromString('Framework/Test.php'...).



You must to use $phar->addFromString('framework/test.php', ...);

(the lowercased name to the spl_auload to find it)


Previous Comments:
------------------------------------------------------------------------
[2010-07-22 20:09:57] jinmoku at hotmail dot com

On OSX 10.6.4



output :



��???�???

Fatal error: Class 'Framework\Test' not found in
/Library/WebServer/Documents/test/index.php on line 26







require_once('Framework\Test.php');

don't run :



��????

Warning: require_once(Framework\Test.php): failed to open stream: No
such file or directory in /Library/WebServer/Documents/test/index.php on
line 26



Fatal error: require_once(): Failed opening required
'Framework\Test.php' (include_path='.:/usr/lib/php') in
/Library/WebServer/Documents/test/index.php on line 26



and phar is not in PATH include_path Windows XP

------------------------------------------------------------------------
[2010-07-22 16:13:14] jinmoku at hotmail dot com

just like http://bugs.php.net/bug.php?id=51991 ;)

------------------------------------------------------------------------
[2010-07-22 16:08:59] jinmoku at hotmail dot com

Description:
------------
spl_autoload_register don't load namespaces file in phar

Test script:
---------------
---- BEGIN TEST CODE ----

$phar = new Phar('MyPhar.phar');



$index = <<<DOC

<?php

        spl_autoload_register();

DOC;



$contents = <<<DOC

<?php

        namespace Framework;

        

        class Test

        {

                public function __construct()

                {

                        echo 'hi';

                }

        }

DOC;

$phar->addFromString('index.php', $index);

$phar->addFromString('Framework/Test.php', $contents);



require_once('MyPhar.phar');

$test = new Framework\Test();

---- END TEST CODE ----



but this follow code work :



require_once('MyPhar.phar');

require_once('Framework\Test.php');

$test = new Framework\Test();





Expected result:
----------------
hi

Actual result:
--------------
Fatal error: spl_autoload() [function.spl-autoload]: Class
Framework\Test could not be loaded


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=52406&edit=1

Reply via email to