Reputation: 295
I have small issue in create a result class where I want to save all error messages in my app Here is my files tree :
Here is my simple Result class:
class Result {
public $errors;
public $data;
public function __construct($errors = array(), $data = null) {
$this->errors = $errors;
$this->data = $data;
}
}
And here is my Home Controller function:
namespace MyApp\Controller;
require_once 'lib/result.php';
class Home extends \SlimController\SlimController
{
public function dataAction()
{
$result = new Result;
}
}
I get error in my PHP built-in server :PHP Fatal error: Class 'MyApp\Controller\Result' not found
Upvotes: 1
Views: 608
Reputation: 11135
You are trying to get the Result
class in the current namespace you could do
$result = new \Result();
or with
use Result;
after the namespace
Upvotes: 2