What is a Package?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

What is a Package?

Post by Ollie Saunders »

I never really completely understood what a package is.

Are they just a class-hierarchy that solves a specific problem?
What is the difference between a package and a specific framework?
Are there naming conventions for packages?
When and where do you use @package phpdoc?
PEAR uses packages, is a PEAR package any different from a normal package?
Is a package exclusive to PHP?
Does a package only feature source code?

As you can see I'm rather confused.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

According to Wikipedia, a package is either a software installation executable (not applicable) or a Java construct that simulates namespaces and groups similar/related classes together.

To me:

properties/methods < classes < packages

Classes can be tightly coupled together, but a package is a fairly opaque supersystem of these classes.
Are they just a class-hierarchy that solves a specific problem?
Yes.
What is the difference between a package and a specific framework?
A framework defines the architecture of a system. A package just sort of hangs out and says, "Hey, use me!"
Are there naming conventions for packages?
PHP doesn't have real namespaces, so I assume Packagename_Classes, although it may be fuzzy.
When and where do you use @package phpdoc?
Never used it.
PEAR uses packages, is a PEAR package any different from a normal package?
Not really, except that it's really, really, really easy to install, and has well defined dependencies to other packages.
Is a package exclusive to PHP?
Of course not!
Does a package only feature source code?
Nope. As PEAR demonstrates, it can contain documentation too! :-P

One final note: don't get too hung up on terms. They can mean many different things. Convention is more important.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I think the traditional meaning of a package is some software accompanied with a title, version number, license and possibly some vendor information. It does not need to be classes, but in some languages with actual Package object (e.g. Java) is ususally means a set of classes. I am sure that PEAR adds it own spin to the meaning. Also Linux package managers like RPM and APT add build and dependency information into the package.
(#10850)
Post Reply