Answer the question
In order to leave comments, you need to log in
Question about the PHP architecture of the project. How to improve?
Need advice on application architecture. Is it optimally built for me now? Which way to look next? What was done wrong in your opinion?
From unaccounted for now - no routing, url refers to a specific page. I haven't planned full MVC yet. Is it worth it?
There is no error output to some kind of automatic bug tracker. Errors and exceptions are handled manually by the test run. Are there analogues of PHPUnit or is it better to learn it?
Project structure -
1. Each page has a main script that checks if the user has access to this page, prepares data for filling the page, renders its own twig template.
2. The template contains a variety of forms and controls. The forms are passed by AJAX to the script responsible for handling the actions of that particular page (add a comment, close the task, edit the response). The script validates the user's data and rights. The script response comes in JSON, parsed - depending on the result, we issue a notification of success / failure.
3. The processing script, depending on the action of the request, pulls the methods of the corresponding classes, throws exceptions in case of an error, the transaction is rolled back in the exception handling (if there were requests to add / change), an error message is generated. Response is given in JSON
4. Classes by entities - user, task, equipment, etc. The methods contain calculations and queries to the database (PDO). Getters and setters are not directly used - no one parameter needs to be updated, the update goes through groups of parameters at once. Where you need to change single fields - methods are written with appropriate checks.
If there is any interesting literature or articles in your opinion, I will be grateful. Thanks in advance!
Answer the question
In order to leave comments, you need to log in
I would still recommend looking towards MVC and trying to build an architecture in accordance with this paradigm. Take a look at how some frameworks, such as Laravel, are arranged. You can also look at Slim3, there is no rigid structure like in large frameworks, and you can create the architecture yourself using the documentation.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question