I'm new to php and OOP, and for learning I started writing an application that would help me and my flatmates to manage our expenses and debts to one another.
The full source is available at https://bitbucket.org/nicocool84/coloc-web/src. I tried to use the MVC(S) architecture without using a framework.
The project tree is as follows:
. ├── controllers │ ├── DebtController.php │ ├── DefaultController.php │ └── UserController.php ├── models │ ├── DebtList.php │ ├── Debt.php │ └── User.php ├── services │ ├── Database.php │ ├── DebtService.php │ ├── RedirectService.php │ └── UserService.php ├── views │ ├── footer.php │ ├── header_logged.php │ ├── header_unlogged.php │ ├── home_unlogged.php │ ├── html_header.php │ ├── jumbotron.php │ └── list_debts.php └── web ├── index.php └── .htaccess
.htaccess redirects all requests to
index.php which decides which controller and which action to call based on the URI:
To handle sessions, when a user is authenticated, I store a
User instance with his details in
$_SESSION. The related methods are stored in
UserService, for instance
getCurrentName. Is this a good practice? Should I create a
SessionService? Should I do this completely differently?
Is creating a
DebtList class to compute who owes what making any sense?
I know the HTML/CSS part is quite ugly, and I'm open to advice there too.
Thanks to anyone who will take the time to review it all.