Reputation: 15889
I have several functions independent from each other and I used to wrap them in one class so I could autoload them via spl_autoload_register()
. But then my utility class is getting so big now it's almost 1000 lines.
Now I'm thinking of separating each function in to each class/file.
If you think this is a good idea what do you think is the best approach:
// load_foo.php
class load_foo
{
public function __construct ($params,..)
{
}
}
// usage
new load_foo($params);
or
// load_foo.php
class load_foo
{
public static function exec ($params,..)
{
}
}
// usage
load_foo::exec($params);
Upvotes: 1
Views: 114
Reputation: 10192
Since apparently you don't use the notion of "objects" then it's best if you use the "static" option, load_foo::exec($params);
That being said, I believe that "separating each function in to each class/file." is overkill, you'll wind up with too many files and classes. Even if the functions are unrelated (as your comments suggest), try putting them in a few files which you load with your autoloader.
On a different note, you can use an accelerator, like APC or xcache. These will keep a pre-compiled version of your code, considerably minimizing the performance impact of loading files.
Upvotes: 1