views:

200

answers:

5

At the beginning PHP was a scripting language. But after the introduction and improvement of OOP I see more and more objects added to the core. They started with libraries like DOM (the PHP 4 and 5 varieties), later SPL which grew a lot, and the DateTime family which should be part of PECL, Pear or Zend Framework or implemented by each one of us.

Shouldn't PHP be only for built-in functions, with all these objects passed to something else?

Example: DateTime class is part of the core and I see it is very similar to Zend_Date.

Wikipedia on standard library.

+7  A: 

There is nothing that says a scripting language should not be object oriented or shouldn't have objects. The SPL (which, as of PHP 5.3, is always available) is a "collection of interfaces and classes that are meant to solve standard problems." (source) It provides useful things not already in the core (data structures, a wide variety of iterators, an expanded set of exception types, OO-APIs for files, improved class autoloading tools) in an more OO way.

I am all in favour of a large standard library that I don't have to debug and provides functions for most of what I want to do. If I want to read an XML file, I shouldn't have to go digging for a library as it is such a common thing to want to do.

DateTime family which should be part of PECL, Pear or Zend Framework or implemented by each one of us.

If it is used by a lot of people, why shouldn't it be in the core? There is no point in everyone implementing a different version of the same thing.

Yacoby
From DOM/Installation/ There is no installation needed to use these functions(na. valid for the classes as well); they are part of the PHP core. DOM support may be disabled with --disable-dom.
Elzo Valugi
Indeed, especially as so many people who reinvent a wheel tend not to make it round. If I had a pound for every time I'd seen a hand-rolled datetime library that didn't cope properly with leap-years, I wouldn't be rich, but I'd certainly be able to buy a lot of beer.
Matt Gibson
I guess everybody missed my point. The contrary of reinventing the wheel is cluttering php with a lot of garbage just because we are lazy. Probably it will be a good idea to include in the core all classes from phpclasses.org?
Elzo Valugi
@Elzo Writing a decent (Daylight Saving Time, Different Calendars, Leap Years etc) and well tested DataTime library is at least two days work. I don't have that much time.
Yacoby
+1  A: 

According to Wikipedia:

A software framework, in computer programming, is an abstraction in which common code providing generic functionality can be selectively overridden or specialized by user code providing specific functionality [...]

This does describe the Zend Framework and projects like CakePHP, but doesn't describe the general trend you're seeing where PHP is becoming more object-oriented. Many languages (Ruby is one example) are completely object-oriented and yet are not frameworks. Ruby on Rails is an example of a framework written in Ruby.

So no, PHP is not becoming a framework.

Josh
+4  A: 

Only build-in functions? Have you ever used languages like Java or C#? If the addition of a few classes and interfaces is turning PHP into a framework those languages are practically operating systems by now.

PHP isn't becoming a framework. It's not even close.

Manos Dilaverakis
Never worked with C# but how big is his standard library? BCL and .net are outside of C# right? All languages have a standard library.. the rest should be in external libraries or frameworks no?
Elzo Valugi
@Elzo - I was referring to .NET as well. You rarely see C# without it after all.
Manos Dilaverakis
+2  A: 

PHP has always been a "framework" for building websites, in the sense that it has specific support for handling web pages and sessions. [Show me any serious application coded in PHP that isn't fundamentally a web site]. IMHO, as a programming langauge, it has little to recommend it, even with the afterthought addition of OO; the only thing that saves PHP is the web support (including the huge library of functions), and the fact that it is free.

As one example of how poorly it carries itself as a langauge, the PHP folks are having trouble with Unicode. The hints about Unicode were loud and clear back in the middle 90s, and every modern langauge since them simply insisted on having direct Unicode support in the language. Hint: PHP wasn't designed; it simply grew.

Ira Baxter
A: 

I think it's transforming into a big library because it's full of goodies but not really anything to tie it all down with a nice ribbon.

A framework such as Zend or Symfony will do wonders for organizing a PHP application. PHP alone, not so good for huge projects.

Serg