You're importing ValueInterface from Javelin\Value namespace, yet the same interface is defined in Domain namespace.
Aug 26, 2018
2
Level 1
Interface Not Found Error in PHP
Hey, so, I am getting this error when running my PHP script.
PHP Fatal error: Interface 'Javelin\Value\ValueInterface' not found in /Users/PatrickL/Documents/Developer/Javelin/src/Value/Value.php on line 23
It is referring to the following file.
<?php
namespace Domain;
use Javelin\Value\ValueInterface;
use Javelin\Exceptions\IllegalConversionException;
/**--------------------------------------------------------------------------
|
| Value
|
-----------------------------------------------------------------------------
|
| A Value represents a Value Object. A Value Object is an object that
| represents a descriptive aspect of a domain with no conceptual
| identity. Value Objects are instanciated to implement design elements
| in which we only care about what they are.
|
-----------------------------------------------------------------------------
*/
abstract class Value implements ValueInterface
{
// Class definition here.
}
More specifically, line 23 is the following:
abstract class Value implements ValueInterface
For reference, ValueInterface (the interface it cannot find) looks like this.
<?php
namespace Domain;
/**--------------------------------------------------------------------------
|
| Value
|
-----------------------------------------------------------------------------
|
| A Value represents a Value Object. A Value Object is an object that
| represents a descriptive aspect of a domain with no conceptual
| identity. Value Objects are instanciated to implement design elements
| in which we only care about what they are.
|
-----------------------------------------------------------------------------
*/
interface ValueInterface
{
/**
* equals() determines if the object is equal to the target
* @param mixed
* @return bool
*/
public function equals($target): bool;
}
?>
And finally, directory structure looks like this:
Javelin
- src
- - Entity
- - Value
- - - Value.php
- - - ValueInterface.php
- <other files and folders>
Any idea on what the issue is? I have a feeling I am not understanding something about namespaces and automatic includes. But, what do you all think?
Thanks for the help.
Please or to participate in this conversation.