PHP - MVC - view selection

Welcome all!

Seek some help with MVC in the context of PHP. I am currently creating a small, lightweight MVC framework to accelerate application development at work. This is a long, tough split that excludes inline code - at least with numerous projects hanging overhead and the temptation to use it ever.

I understand most of the basic requirements of MVC, and I have already started transferring some of my existing classes that are in the Singleton template, as utilities in my new structure (these are basically the basic “handlers” for performing site services - a class for downloading files, authorization, completed PDO database queries, error printing, etc.)

What I cannot understand, moving forward after reading a lot of documentation is the best approach to creating instances. In my old, inefficient design, I would disable the $ _GET variable to switch the output from the internal view. Just moving away from intuition, this seems like a very bad way to get the job done.

I am looking through CodeIgniter, and it seems that there are predefined functions for loading views within this framework. What is the best approach to this application design? Will it be a “factory reference” based on a class that uses the same variables to retrieve content, select the correct view file and place it in the page stream? Also, how can you include a new view between the header and footer in the root index without using switches? This is the only thing that really baffles me - I really hope that I have articulated myself clearly enough.

Thanks to everyone, as always!

+3
source share
2 answers

"PHP-, " . MVC- .

( ):

+2

, (, Zend), , , (, , , ).

  • - ( ) . , .
  • ( ) , , . , , , , .
  • .

.

+2
source

Source: https://habr.com/ru/post/1725287/


All Articles