B
B
banny_name2015-09-26 10:36:29
PHP
banny_name, 2015-09-26 10:36:29

What is the abstraction for http, Request and Response in mvc framework?

I'm parsing the mvc framework...
In routing, the Request class stores abstraction data for http -> I don't understand what it is and why at all?
also, before there was no Response class, but the controller was simply called, the controller processed and called the view (require view.php)
now the Response class displays view.php via echo (that is, the controller returns the content of the view, and Response displays it via echo )
Why all this ?
Explain, please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
HaruAtari, 2015-09-26
@banny_name

Honestly, this is the first time I hear about this framework. Yes, and it is difficult to call it a framework. I looked at the source code a bit (are they ?). Made, to put it mildly, through one place. Yes, and there is practically nothing there. If you want to deal with MVC, check out the same Yii for example.
Regarding your specific question. Response and Request are used to abstract away the handling of the I/O stream. Response, for example, will set the necessary headers for you. Request will provide a convenient wrapper for accessing $_POST and $_GET requests. This is naturally not all.
The point is that you don't have to deal with low-level stuff directly. You access them through an abstraction, which also provides a bunch of different conveniences. Plus, you are not working with global data, but with a specific object that you received in a method.
Why renders through echo - xs. In yii, for example, this happens:

public function renderPhpFile($_file_, $_params_ = [])
{
    ob_start();
    ob_implicit_flush(false);
    extract($_params_, EXTR_OVERWRITE);
    require($_file_);
    return ob_get_clean();
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question