-1

I have my own MVC and autoloader that loads classes. Everything works except that my base View.php is in Core folder and its render function does the following:

   public function render($file) {
        include('Project/Views/index/header.php');
        include('Project/Views/'.strtolower($file).'.php');
        include('Project/Views/index/footer.php');
   }

View.php uses a namespace

namespace Core;

when i go to my index page it gives:

Warning: include(Projcet/Views/index/header.php): failed to open stream: No such file ...

I tried the following: i added

use Project\Views;

and instead of include i did:

$header = new Views\index\header();

This shows the header on the page but it also gives an error:

'Project\Views\index\header' not found

I know its because header.php is not a class. It's a view file. So I don't know, how to include the file, when autoloader is loading the View.php for base Controller.

tereško
  • 58,060
  • 25
  • 98
  • 150
Giorgi
  • 609
  • 2
  • 15
  • 29

1 Answers1

1

The error message (if you copy-pasted it verbatim) looks like you're including files from the wrong folder:

Warning: include(Projcet/Views/index/header.php): failed to open stream: No such file ...

Mihai Stancu
  • 15,848
  • 2
  • 33
  • 51
  • im embarrassed :( how could not i see that. thanks alot – Giorgi Sep 08 '12 at 18:07
  • More often that not, you're working on something for so long that you become paranoid as to what (complex) issue might arise to stop you in your tracks. The resolution is always the same: for fear of bigger issues you've overlooked the smaller ones. – Mihai Stancu Sep 08 '12 at 18:24