Using an object-oriented programming approach rather than a procedural approach to programming in a program does not really depend on the language (whether PHP or not), but on the type of problem you are trying to solve.
(I will just use pseudo-code in my examples, as I am not very familiar with PHP.)
For example, if you have a program in which you simply perform a bunch of functions in order, then the procedure will be fine. For example, if this is a simple string-processing program, a procedural approach is enough:
perform_truncation(my_string, 10) to_upper(my_string) perform_magic(my_string, hat, rabbit)
However, if you are going to deal with many different elements (for example, files or any other representation of the objects of the desired object), then an object-oriented approach would be better.
For example, if you have a bunch of Car and you want them to be drive , then in the procedure you can do something line by line:
drive_car(first_car) drive_car(second_car)
Where, in OOP, Car can control itself:
RedCar myRedCar(); BlueCar myBlueCar(); myRedCar.drive(); myBlueCar.drive();
And, since each car is a different class, their behavior can be defined in different ways. In addition, they can be either subclasses or Car , they can have common functionality.
It really comes down to the type of problem that makes either a procedural approach better than an object-oriented approach, and vice versa.
Besides the problem of procedural or object-oriented, it can be a kind of âcode smellâ to have one source file with many functions. This can also be said of classes that contain a lot of functionality that can better be performed as separate functions in separate classes.
The problem here may be with the organization of the code, and not with the choice of procedural or object-oriented programming. Perhaps there are functions for organizing individual source files, except for abandoning the procedural approach to writing a program.
After all, there are many programs written in procedural programming that are well written and easy to maintain.