Inform or not the view inside the controller in php?

4

I created a framework for my own use, a bit for understanding how an fw works, but it turned out to be a basic working tool. I know that many will say that one should not try to reinvent the wheel. But I'm not trying to do this, I'm just wanting to learn how to make the wheel.

My idea is to put the controller name as the folder of my view, and the method inside the controller as the file.

To exemplify:

class Home {

public function login() {
//aqui iria meu código
}

In this case, my system would look in the folder for the HOME folder and inside the folder, it would look for the LOGIN file inside it (would see views / HOME / LOGIN.view. php).

The question is: In what situations could I have system disorders? Remembering that if I want to have several controllers and only one url, just set the url in those controllers, if not, it will search by default for the controller name and method, as mentioned above.

    
asked by anonymous 20.06.2016 / 03:27

1 answer

3

I think that anyone who says that bullshit is reinventing the wheel is not aware of the issue, it is often better to work with a framework that works harder and not know how to use it properly, or meade of the resources of it and to have several useless files in the system.

If I want to have multiple controllers and just one url

I did not really understand what that meant, how would I define which controller, model and view I would call?

Normally the default is: domain.org/controller/metodo/parametros

Only if your parameters were with the post method, hence the url would always be: domain.org, but I do not think this is legal, since the user would get a request and if the site had a share option it would not work well. p>

Now, about the question itself, the only possible disruption would be if the respective view of that method did not exist, you would have to handle the error and another catch would be if a public method did not have a view, as usually happens with the method turn off.

If I wanted to make this automatic view call I suggest that I also create a method for the developer to set a different view for the method, if he does not call this method then you call the method that defines the default view. And let a method also for the view be disabled in that method, to be used when the method does not normally have a view, such as delete.

I do not see any more problems this can cause.

    
20.06.2016 / 14:54