Answer the question
In order to leave comments, you need to log in
Did I understand how frameworks work correctly?
Did I understand correctly that from the framework, roughly speaking, I use routes, controller and views. This is a frame. In the controller I use ready-made functions, for example, working with the database. But if I want to write, for example, cropping a photo with a square, then should I implement my own bike? That is, half of the functionality is the functions of the framework, half are my bikes...
Answer the question
In order to leave comments, you need to log in
If it is work with photos, then there is a "mountain" of ready-made libraries, for example, image.intervention.io/getting_started/installation...
Frameworks are a set of ready-made solutions for standard tasks. Think of them as a bunch of separate libraries. Let's say it makes no sense to write again and again the routing of requests, etc. from time to time.
The main task of the controller is to be an intermediary between the presentation of data (HTTP, for example, or a web interface, or CLI) and the logic of their processing. That is, you can work with the database in the controller, but it is not recommended (only if you know what this can lead to and why thick controllers are bad).
The rest of the application logic, business logic, is pure and beautiful PHP. For convenience, sometimes you can slightly increase the cohesion of the application code and libraries that you use, but again, this is not very good and you should understand what this can lead to.
Similar functionality, cropping pictures, working with graphics, etc. already implemented before you. Usually, all a developer needs to do is wrap it up with a beautiful interface that will hide all the details of how images are processed.
Not great, but business logic. The framework provides you with a framework, a solution to common problems. In the case of simple CRUD, the ratio of your code to library framework code can be 1/10. In the case of complex business logic and specific infrastructure - 10/1.
the framework gives you a set of ready-made tools that you customize to fit your needs. and with good logic and the ability to use it, many bicycles can be avoided.
ZY work with basis, usually, goes in models where MVC structure. controllers accumulate and process everything that you invent and give to the view.
routes, controller and views
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question