我正在使用 PHP 在最近更新中实现的美妙的新命名空间特性创建一个库。但是,我需要在我的一个类中使用 simple_html_dom.php 类。我正在使用符合标准 PSR-0 的自动加载器类,但由于下划线,在尝试创建 simple_html_dom 类的新对象时出现错误。
在查看我的自动加载器类时,它用下划线代替了重击。这很容易解决,但我担心它可能会破坏我的 PSR-0 合规性。我想知道解决遗留库的此类问题的最佳实践是什么。
目录结构
- vendor/
  - MyStuff/
    - lib/
      - simple_html_dom.php
    - MyClass1.php
MyClass1.php
<?php
namespace MyStuff;
// This require works
require(__DIR__ . '/lib/simple_html_dom.php');
class MyClass1 {
    public function __construct() {
         // This breaks
         // Warning: require(C:\www\vendor\LoU\simple\html\dom.php): failed to open stream
         $html = new simple_html_dom();
    }
}