T
T
TiglathPileser2019-10-04 22:14:03
PHP
TiglathPileser, 2019-10-04 22:14:03

How to split into classes?

I am learning PHP. I am making a WordPress plugin. Interested in what classes are better to create or just write as you would write (divided into classes).
Given:
- Plugin.
- It has data (for example, one string field and one checkbox)
Depending on the "place of execution", different actions are needed. There can be 3 "places of execution":
- Ajax
- Admin
- Frontend
In all 3 places plugin data is used and everywhere you need to perform many different actions, somewhere the plugin must provide methods to external code.
I hope I wrote clearly, I don’t want to delve into the code. it is the division into classes that is of interest, maybe some classes should be static, etc.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2019-10-05
@FanatPHP

I am learning to draw. Interested in what colors to use. I do not want to delve into the plot, I just wonder what colors are needed.
The question is meaningless.
The answer is simple - do not use any classes. With this level of questioning, you need to forget about OOP and first learn to structure your thoughts, then your procedural code, and then, when it finally starts to work out in five years, the classes will fall into your hands.

T
TiglathPileser, 2019-10-06
@TiglathPileser

Made the variant, only a framework of classes. I did not implement the actions that need to be performed for simplicity, I replaced them with the output of a text message.
https://github.com/sergo5000/test

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question