Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Has anyone attempted to make PHP's system functions more Object-Oriented?

Tags:

oop

php

wrapper

I'm just curious if any project exists that attempts to group all (or most) of PHP's built-in functions into a more object-oriented class hierarchy. For example, grouping all the string functions into a single String class, etc.

I realize this won't actually solve any problems (unless the modifications took place at the PHP source code level), since all the built-in functions would still be accessible in the global namespace, but it would certainly make usability much easier.

like image 251
Wilco Avatar asked Sep 15 '08 01:09

Wilco


3 Answers

Way too many times. As soon as someone discovers that PHP has OO features they want to wrap everything in classes.

The point to the OO stuff in PHP is so that you can architect your solutions in whichever way you want. But wrapping the existing functions in Objects doesn't yield much payoff.

That being said PHP's core is quite object oriented already. Take a look at SPL.

like image 102
Allain Lalonde Avatar answered Oct 10 '22 15:10

Allain Lalonde


I think something like this is intergral for PHP to move forward. Being mainly a .Net programmer, I find PHP painful to work in with it's 1 million and 1 global functions. It's nice that PHP 5.3 has namespaces, but it doesn't help things much when their own libraries aren't even object oriented, let alone employ namespaces. I don't mind PHP as a language so much, but their API is terribly disorganized, and it probably needs a complete overhaul. Kind of like what VB went through when it became VB.Net.

like image 44
Kibbee Avatar answered Oct 10 '22 14:10

Kibbee


To Answer your question, Yes there exists several of libraries that do exactly what you are talking about. As far as which one you want to use is an entirely different question. PHPClasses and pear.org are good places to start looking for such libraries.

Update: As the others have suggested SPL is a good library and wraps many of built in php functions. However there still are lots of php functions that it does not wrap. Leaving us still without a silver bullet.

In using frameworks such as Cakephp and Zend (others too), I have noticed that they attempt to solve some of these problems by including their own libraries and building basics such as DB connectivity into the frame work. So frameworks may be another solution

like image 41
SeanDowney Avatar answered Oct 10 '22 16:10

SeanDowney