douzhong8856 2018-05-30 11:40
浏览 944

'vendor / autoload.php'错误,composer全局安装

I installed composer globally and when I run my mail php example I get the following errors:

Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/emailexample/index.php on line 9

Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/emailexample/index.php on line 9

I appreciate any advice on resolving these errors.

  • 写回答

1条回答 默认 最新

  • dongpi0658 2018-06-01 09:32
    关注

    I'm afraid you misunderstood what Composer is and what installing it globally means. Composer is a tool for installing dependencies in your project. Installing it globally means that you can use this tool from any place in your system, but it doesn't mean that it will magically resolve all dependencies from all of your project - you need to call Composer manually to declare and install required dependencies.

    So if you have composer.json file in /Applications/XAMPP/xamppfiles/htdocs/emailexample you should go into your project directory and install required dependencies:

    cd  /Applications/XAMPP/xamppfiles/htdocs/emailexample
    composer install
    

    If you don't have composer.json you need to define your dependencies first. You can read more about it in documentation, and dependencies should be defined in source of your "mail php example" project. But in general you can add dependencies by:

    cd  /Applications/XAMPP/xamppfiles/htdocs/emailexample
    composer require package/name
    

    Where package/name is name of dependency - you should replace it with real name.

    After installing dependencies make sure that you include composer autoloader in your index.php - you should have something like this before using any class:

    require_once __DIR__  . '/vendor/autoload.php':
    
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助