Reputation: 43
This isn't so much of a how do you do something, but more of a best practice question.
I'm building a simple login application for an internal project using the php-advanced-login framework. The way I'm validating the login form, password reset and login via cookie using using a class that is initialized when a user submits the form. The class then validates everything and any errors are returned in an array and shown in the form.
<?php if(isset($_POST['submit_login'])){
//load class
}
<!doctype html>
//form
My questions is, having everything in this class seems like a bit of a mess (it seems like it's harder to maintain than how I use to do it explained further on), it's all in there because there is lots of code re-use. The way I've done it before is just to split my code up into several php files with functions and just include them when needed. Each php file is a lot shorter and easier to maintain in my opinion. I don't use any real advantages of using a class over just methods.
Whats your opinion on this if you've managed to follow my rambling? Should I use a class and have everything together, just use functions, another better way?
Upvotes: 0
Views: 351
Reputation: 3483
Since you mentioned in the comments that you don't want to use a framework I think the cleanest way to do this is at least mimic some of the features of most frameworks. This includes:
BTW The github repo you linked to is unmaintained
Upvotes: 1