PHP Underscores vs. Directory separators

Silas2
Silas2 used Ask the Experts™
on
Forgive my ignorance on this, but when I run composer to install magium examples, i notice many of the class names have underscores, e.g. PHPUnit_Framework_Test, but when I look in the autoload_static.php i see :
        'PHPUnit\\Framework\\Test' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Test.php',

Open in new window

and the files are not loading properly. Is this some setting I haven't set?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016

Commented:
There must be a little more to the code, right?  By itself, that looks like a parse error.

I think the backslashes\\ are related to PHP namespaces.  The underscores__ are part of the magic constant's name.  Underscores are legit characters in PHP variable and constant names.
http://php.net/manual/en/language.constants.predefined.php

Author

Commented:
Thanks Ray, I just did a hack on the classloader.php to find the files, and now I'm getting a brick wall on
" implements \PHPUnit_Framework_TestListener"
Its not using the classloader.php to look for it....

Author

Commented:
Generally speaking, I've downloaded a test project with loads of dependencies, and I see some pointing to AppData\Local\Temp\$Metadata$\B49847A5$phpunit-4.5.phar/PHPUnit_Framework_TestCase.php (which i didn't knowingly download) and I see references broken there....I'm sure this the php version of 'DLL Hell', I was hoping the composer would take care of this stuff..

Author

Commented:
Whats' the best way out of this ?
Most Valuable Expert 2011
Top Expert 2016
Commented:
The best way out may be to start over with a clean install of your dependencies.  When I take on a new framework or any other complicated activity, especially when I'm going into unfamiliar territory, I like to use Bitnami stacks.  You can download a free VM, spin it up, hack away at it, and if things go wrong, just dump it and start over.

Implements is a term of art in PHP object-oriented design.  When you see the implements keyword, you know that the next thing is the name of the interface or interfaces.  You can consult the design of these interfaces to see what code you need to write in a class that implements the interface.  Contrast abstract classes, where part of the class is already built.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial