doushang8512 2017-06-07 08:05
浏览 13

找不到xml类

I am trying to work with fluidxml to test if I can use it, but I cant get it to start working, I am using codeigniter framework. I cloned the repo https://github.com/servo-php/fluidxml and added it to a folder I created called thirdparty. Then here is the code for the function

public function xmltrial(){
        $this->load->helper('file'); 
        require_once(APPPATH.'third_party/fluidxml/source/FluidXml.php');

        $book = new FluidXml();
        $book->add([ 'title'  => 'The Theory Of Everything',
             'author' => 'S. Hawking',
             'chapters' => [
                    [ 'chapter' => [
                            '@id' => '1',
                            '@'   => 'Ideas About The Universe' ] ],
                    [ 'chapter' => [
                            '@id' => '2',
                            '@'   => 'The Expanding Universe' ] ],
           ]]);

        echo $book;
    }

So I am getting two errors , one is Fatal error: Class 'FluidXml' not found even and the second one is if I use use function \FluidXml\fluidxml; use function \FluidXml\fluidns; use function \FluidXml\fluidify; all this character inside my xmltrial function it shows a red error on them.

  • 写回答

1条回答 默认 最新

  • douhuan1950 2017-06-07 10:19
    关注

    You should use composer to manage your dependencies. Get composer installed, then install FluidXml into the vendor folder by typing

    composer require servo/fluidxml

    in the command line. Then you can

    require_once 'vendor/autoload.php'

    in your index.php, and you can forget about having to require in the files! You just need to put the relevant use statement under your namespace declaration.In your case,

    use FluidXml\FluidXml;

    Now you can start calling your class!

    See Packagist for composer package details https://packagist.org/packages/servo/fluidxml

    See Composer site to get composer into CodeIgniter if you don't already https://getcomposer.org/

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog