{
"autoload": {
"psr-4": {
"Acme\\": "src"
}
}
}
インターフェイスはCに位置しています自動ロードPSR-4名前空間のインターフェースは
namespace Acme;
Interface Responds
{
public function userRegisteredSuccessfuly();
public function userRegisteredunSuccessfuly();
}
私composer.jsonファイルに見つかりません:\ xamppの\ htdocsに\ Bootcampの\ SRC \ respondstouserregistration.php
<?php
namespace Acme;
class RegisterUser
{
public function execute(array $data, Responds $listener) //data
{
var_dump('registering the user.');
$listener->userRegisteredSuccessfuly();
}
}
RegisterUserで参照されるインターフェイスは応答し、registeruserもsrcにあります
<?php
namespace Acme;
class AuthController implements Responds
{
protected $registration;
public function __construct(RegisterUser $registration)
{
$this->registration = $registration;
}
public function register()
{
$this->registration->execute([], $this);
}
public function userRegisteredSuccessfuly()
{
var_dump('created successfuly. redirect somewhere.');
}
public function userRegisteredunSuccessfuly()
{
var_dump('created unsuccessfuly. redirect back.');
}
}
そしてこのクラスで私は応答インターフェースを実装しました。
はAuthControllerもCに位置しています:\ XAMPP \ htdocsに\ Bootcampのは、\ SRC \ authcontroller.php
が今私のエラーはオートローディングは、あなたのクラス名がファイル名と一致すると仮定し
PHP Fatal error: Interface 'Acme\Responds' not found in C:\xampp\htdocs\bootcamp\src\authcontroller.php How can i make the Authcontroller locate the php file where the interface is?
ありがとうございます。 –