File 1 - /Users/jitendraojha/www/DesignPatternsWithPhpLanguage/FactoryPattern/FactoryClassPattern/UserInterface.php
<?php
namespace DesignPatternsWithPhpLanguage\FactoryPattern\FactoryClassPattern;
interface UserInterface
{
function setFirstName($firstName);
function getFirstName();
}
?>
File 2 - /Users/jitendraojha/www/DesignPatternsWithPhpLanguage/FactoryPattern/FactoryClassPattern/User.php
<?php
namespace DesignPatternsWithPhpLanguage\FactoryPattern\FactoryClassPattern;
class User implements UserInterface
{
private $firstName = null;
public function __construct($params) { }
public function setFirstName($firstName)
{
$this->firstName = $firstName;
}
public function getFirstName()
{
return $this->firstName;
}
}
?>
Problem
php FactoryPattern/FactoryClassPattern/UserInterface.php - works fine.
php FactoryPattern/FactoryClassPattern/User.php - gives the following errors: PHP Fatal error: the interface 'DesignPatternsWithPhpLanguage \ FactoryPattern \ FactoryClassPattern \ UserInterface' was not found in /Users/jitendraojha/www/DesignPatternsWithPhpLanguage/FactoryPattern/FactoryClassPattern/User/Unit
I added use UserInterface;to file 2 without a solution.
source
share