Is there a way to implement this idea
class Test{
public function test(){
return include 'test.php';
}
}
test.php
<?php
// process the functions here (including queries , etc)
return 1;
?>
Test
$test = new Test();
echo $test->test();
Basically, it's a combination of OOP and Procedural approach. The main goal here is to separate the process of the functions and put it on another file. The purpose is lessen the lines of the code from the class and make it easier to trace instead of scrolling to 1000+ lines of codes.
PS. I'm sorry for the title. I am not sure if this is possible but I hope you could give me idea.
Thanks and Have a nice day!
what you can do is to aggregate an other class (which can sit in an other file) and call a method of this:
Main Class: Test.php
while the other class will look like this (
OtherClass.php):Further ...
if you have a class which you want to mix in your classes, you can use the concept of mixins, which are called traits in php.
The
OtherClass.phpwill change toand the
Test.phpclass would change to:If you are new to OOP or Programming I can reccomand two books by Robert Martin:
"Clean Code" and "Clean Architecture".
And to get better in PhP I can recommand this website: https://phptherightway.com/