Re: PEAR2 package naming standards (namespace usage)
| From: | David Jean Louis | Date: | Wed, 27 Aug 2008 09:16:41 +0000 |
| Subject: | Re: PEAR2 package naming standards (namespace usage) | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-50645@lists.php.net to get a copy of this message | ||
Travis Swicegood a écrit :
Hey everyone; This summer the PEAR group has been busy making sure PEAR2's ducks are all in a row for the impending PHP 5.3 release. The biggest change that we're all going to get used to in this new version of PHP is namespaces. The quick way to migrate is to replace all _ with ::, shorten some class names, but that ignores this very rare chance to really re-think the way we do package names. The results of some back and forth between myself and the rest of the PEAR Group and other members of the community is this RFC:Hey there, I really prefer the initial proposal (replace all _ with ::), IMHO the svn:externals problem should not dictate the namespace naming decision. With the current proposal, what if I want to do the following ? <?php // my script want to use Console_CommandLine *and* Console_Color use PEAR2::Console; $commandline = new CommandLine();http://wiki.pear.php.net/index.php/PEAR2_Naming_StandardsPlease review it and post your thoughts here for discussion. It is slated for a vote @ the next PEAR Group meeting on September 14th, so now is your opportunity to sway our opinion. -T
$color = new Color();// etc... ?> Also, in the RFC, you mention the MDB2 example, to me: "PEAR2::MDB2::Driver::MySQL" is way clearer than "pear2::mdb2_mysqldriver::Driver". And I want to be able to easily switch between "drivers" or "adapters": <?php // the drivers namespace use PEAR2::Foo::Driver; if ($some_condition) {
// use foo driver
$driver = new Foo(...);
} else {
// use bar driver
$driver = new Bar(...);
}
?>
With your proposal, I guess I would have to do:
<?php
if ($some_condition) {
// use foo driver
use pear2::foo_foodriver;
$driver = new Driver(...);
} else {
// use bar driver
use pear2::foo_bardriver;
$driver = new Driver(...);
}
?>
Speaking of the lowercase idea, I'm all for it, but I think this decision must be taken considering choices made by others (PHP, SPL etc...), I would not want to end with things like this in my code:
<?php
$it = new SPL::DirectoryIterator();
$bar = new pear2::foo::bar::Baz();
$elt = new SimpleXML::Element();
?>
--
David