Proposal for unified namespace organization | drupal.org
Drupal
Drupal\Component\$component
Drupal\Core\$subsytem
Drupal\Module\$module
Drupal\Hook and Drupal\Module\$module\Hook
Drupal
Drupal\Component\$component
Drupal\Core\$subsytem
Drupal\Module\$module
Drupal\Hook and Drupal\Module\$module\Hook
Modules and themes (and engines) would have a namespace such as
namespace drupal\taxonomy;
or
namespace drupal\bartik;
Function prefixes, such as 'taxonomy_' would be dropped.
However, this makes Drupal code really ugly.
Calling functions not in a module from a module would look like this:
\drupal\set_message();
Calling a db function would look like this:
\drupaldb\select('node');
Calling an API function in another module would look like:
\drupal\taxonomy\select_nodes();
The solution? Namespace importing.
At the very least (if we are on PHP 5.3) we could have something like:
namespace drupal\dblog;
at the top of every file.
Files in the includes directory would have:
namespace drupal;
The only time 'drupal' would be seen in a function name would be when calling an API function in a different module, e.g.
\drupal\system\flush_caches();
1) We've been discussing how and if to leverage PHP namespaces in Drupal 8, now that we have access to them in PHP 5.3. To date most of the discussion has been on tricking out modules-as-namespace, a discussion that has stalled as it is a much more complicated problem space than it seems at first glance.
There are three ways to access a file in a file system:
Relative file name like foo.txt. This resolves to currentdirectory/foo.txt where currentdirectory is the directory currently occupied. So if the current directory is /home/foo, the name resolves to /home/foo/foo.txt.
Relative path name like subdirectory/foo.txt. This resolves to currentdirectory/subdirectory/foo.txt.
Absolute path name like /main/foo.txt. This resolves to /main/foo.txt.