0

Is Heredoc in MVC a good way to begin my foray into separating layers? I read one place it could be use and another that heredoc had more problems than it solved.

johnny
  • 19,272
  • 52
  • 157
  • 259
  • heredoc is a syntax unless I'm mistaken. Quick google didn't turn up any MVC frameworks called that. – Chuck Vose Sep 24 '10 at 21:15
  • Honestly though, if you can convince your company please just jump ship already and learn Django or Rails. – Chuck Vose Sep 24 '10 at 21:16
  • 2
    @Chuck could you please leave language bias out of here? HEREDOC is supported in Python and Ruby as well, so even if the OP would jump ship, your "advice" would not get him anywhere. – Gordon Sep 24 '10 at 21:33

2 Answers2

3

No. HEREDOC is completely unrelated to MVC. HEREDOC is just one way to delimit strings. It's the same as asking whether Single or Double quotes are good way to separate layers.

MVC's idea is to split the user interface into three separate roles. I have answered this a few minutes before in your other MVC question, so I just link you to it. There is also a number of good other questions on SO about MVC. Just use the Search function.

Community
  • 1
  • 1
Gordon
  • 312,688
  • 75
  • 539
  • 559
1

Heredoc is a method of sorts, but, no it is not a good way. Especially if you are doing this inside of the controller. You should separate your "view" logic into different files then you would just include the view you need depending on the controller / action.

Doing it as an include you can easily use <?php echo $variable; ?> and do your view logic in that file. You might also consider using a prebuilt framework, such as Zend or Codeigniter, among others which take the MVC approach.

Jim
  • 18,673
  • 5
  • 49
  • 65