Question
Is it possible to create packages of related classes and have the same protected
and private
fields which are visible only to classes from within the same package?
Basically, the same type of packages as what Java has. Is it possible?
Solution
Right now, there is no concept of package.
However, PHP 5.3 is going to introduce namespaces. I'm not sure about how that will affect visibility between classes.
OTHER TIPS
Nope. PHP has no package or friend-class support.
You might be interested to read http://philsturgeon.co.uk/blog/2012/03/packages-the-way-forward-for-php
Short answer - http://getcomposer.org/
Here are two approaches I've stumbled upon pondering the same issue:
PHP Package Management and Autoloading
And it looks like there are some more import analogs in the PHP require_once() docs. Hope it helps someone going forward.