Inform or not the View inside the php controller?

Asked

Viewed 63 times

4

I created a framework for own use, a little to understand how a Fw works, but turned into 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 my view folder, and the method inside the controller as the file.

To illustrate:

class Home {

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

In that case, my system would search the folder views folder HOME and inside the folder, would search the file LOGIN within it ( would be views/HOME/LOGIN.view.php ).

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

1 answer

3


I think that anyone who talks that is bullshit and that is reinventing the wheel has no knowledge on the subject, it is often better to work with a framework of its own that work vom more robust and not know use-it properly, or not even use the mea of its resources and have several useless files on the system.

if I want to have several controllers and only one url

I honestly didn’t understand what that meant, because how would I define which controller, model and view would call?

Usually default is: domain.org/controller/method/parameters

Only if your parameters were with the post method, then the url would always be: dominio.org, but I don’t think this is cool, because the user would be half-asked and if the site had a share option it wouldn’t work well.

Now, on the question itself, the only possible inconvenience would be if the respective view of that method did not exist,.

If you wanted to make this automatic view call I suggest that I also created a method so that the developer can define a different view for the method, if it does not call this method then Voce calls the method that defines the default view. And let a method also so that the view can be disabled in that method, to be used when the method normally does not have a view, like deleting it.

I don’t see any more trouble this can cause.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.