douhuang4166 2017-06-12 11:01
浏览 37
已采纳

使用Composer在PHP项目中加载类

I have difficulties to use this project : https://github.com/php-sepa-xml/php-sepa-xml

I set up everything with composer but I don't know how to generate the xml file.

In the doc folder, there is a sample file, I copy / paste the content in a new php file

<?php
use Digitick\Sepa\TransferFile\Factory\TransferFileFacadeFactory;
use Digitick\Sepa\PaymentInformation;

// Code....
?>

when I run the code I have an error:

Fatal error: Uncaught Error: Class 'Digitick\Sepa\TransferFile\Factory\TransferFileFacadeFactory' not found
 in C:\dev\php-sepa-xml\vendor\digitick\sepa-xml\lib\sample.php:5

I tried to move my php file in different folders and also to change the path but I always have the error.

Note: I'm on Windows so the path may be different.

  • 写回答

1条回答 默认 最新

  • doushou1298 2017-06-12 11:06
    关注

    If you set it up using composer, please add autoloader in the top of php file.

    <?php
    require "vendor/autoload.php";
    use Digitick\Sepa\TransferFile\Factory\TransferFileFacadeFactory;
    use Digitick\Sepa\PaymentInformation;
    
    // Code....
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题