Using an object-oriented programming approach rather than a procedural programming approach in a program doesn't really depend on the language (be it PHP or not), but on the type of problem you are trying to solve.
(I'm just going to use pseudocode in my examples as I am not too familiar with PHP.)
For example, if you have a program where you are just performing a bunch of functions in order, then procedural is going to be fine. For example, if it's a simple string manipulation program, a procedural approach would suffice:
perform_truncation(my_string, 10)
to_upper(my_string)
perform_magic(my_string, hat, rabbit)
However, if you're going to deal with many different items (such as files, or any other representation of, well, objects) then an object-oriented approach would be better.
For example, if you had a bunch of Car
s and wanted them to drive
, then in procedural, you may do something along the line of:
drive_car(first_car)
drive_car(second_car)
Where as, in OOP, the Car
can drive itself:
RedCar myRedCar();
BlueCar myBlueCar();
myRedCar.drive();
myBlueCar.drive();
And, as each car is a different class, their behavior can be defined differently. Furthermore, they may be both subclasses or Car
they may have common functionality.
It really comes down to the type of problem which makes either procedural approach better than object-orientated and vice versa.
Aside from the issue of procedural or object-oriented, it may be a kind of "code smell" to have one source file with many functions. This can also be said about classes which contain many functionalities which may be better performed as separate functions in separate classes.
The issue here may be of code organization rather than deciding to pick procedural or object-oriented programming. Organizing functions into separate source files may be what's needed here than to abandon the procedural approach to writing the program.
After all, there are plenty of programs written in the procedural programming approach which is well-written and easy to maintain.