【问题标题】:php error at runtime Interface 'Psr\Container\ContainerInterface' not found找不到运行时接口'Psr\Container\ContainerInterface'的php错误
【发布时间】:2017-09-27 18:33:46
【问题描述】:

我最近向我正在开发的 PHP 应用程序上传了一个新依赖项,现在我在 Postman 中不断收到以下错误

致命错误:找不到接口“Psr\Container\ContainerInterface” /var/www/html/api/vendor/container-interop/container-interop/src/Interop/Container/ContainerInterface.php上线 13

我已经更新了作曲家以及许多其他内容,但似乎仍然无法确定问题所在。 (也不确定是index.php文件还是container.php文件出错)

这是 container.interface.php 文件中的代码

<?php
/**
 * @license http://www.opensource.org/licenses/mit-license.php MIT 
(see the LICENSE file)
 */

namespace Interop\Container;

use Psr\Container\ContainerInterface as PsrContainerInterface;

/**
 * Describes the interface of a container that exposes methods to 
   read its entries.
 */
   interface ContainerInterface extends PsrContainerInterface
   {
   }

这是我的 index.php 文件中的初始代码

<?php

ini_set('display_errors', 1);

// Include the SDK using the Composer autoloader
require 'vendor/autoload.php';
use Kreait\Firebase\Factory;
use Kreait\Firebase\ServiceAccount;

// Includes ;
require_once( 'config/database.php' );
require_once( 'controller/base.php' );



//$app = new Slim\App();
 $app = new Slim\App(['settings' => ['displayErrorDetails' => true]]);

 $twilio = new Twilio\Rest\Client(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN);
     $serviceAccount = ServiceAccount::fromJsonFile('my_file.json');
     $firebase = (new Factory)->withServiceAccount($serviceAccount)-
      >withDatabaseUri('my_firebase_website')->create();

【问题讨论】:

  • composer.json 的内容是什么?
  • 我不确定,但你能试试这个interface PsrContainerInterface extends PsrContainerInterface 而不是interface C ontainerInterface extends PsrContainerInterface 吗?
  • @Aknosis { "require": { "slim/slim": "^3.7", "twilio/sdk": "^5.4", "nategood/httpful": "^0.2.20" , "kreait/firebase-php": "^3.0", "psr/log": "^1.0", "mdanter/ecc": "^0.4.2" } }
  • @NandanBhat 在你的建议下我替换了类名并得到以下错误
  • @NandanBhat
    致命错误:无法声明类 Interop\Container\PsrContainerInterface,因为该名称已在 /var/www/html/ 中使用api/vendor/container-interop/container-interop/src/Interop/Container/ContainerInterface.php 上线 13

标签: php composer-php slim psr-7 psr-11


【解决方案1】:

解决方案:我正在使用 filezilla 从本地机器上的供应商文件夹中传输更新的依赖项,在此过程中我下载了错误的 autoload.php 文件

【讨论】:

    猜你喜欢
    • 2019-05-06
    • 2021-06-06
    • 1970-01-01
    • 2015-08-23
    • 1970-01-01
    • 2016-03-22
    • 2016-11-18
    • 1970-01-01
    • 2019-10-09
    相关资源
    最近更新 更多