$files->getNamespace() method

Get the namespace used in the given .php or .module file


// basic usage
$string = $files->getNamespace(string $file);

// usage with all arguments
$string = $files->getNamespace(string $file, bool $fileIsContents = false);



File name or file data (if file data, specify true for 2nd argument)

fileIsContents (optional)bool

Specify true if the given $file is actually the contents of the file, rather than file name.

Return value


Actual found namespace or "\" (root namespace) if none found

$files methods and properties

API reference based on ProcessWire core version 3.0.228

Latest news

  • ProcessWire Weekly #489
    In the 489th issue of ProcessWire Weekly we'll check out what's new in the core this week, share a brand-new recipe of the week, and more. Read on!
    Weekly.pw / 23 September 2023
  • ProcessWire 3.0.226 new main/master version
    After 8 months in development we are excited to bring you ProcessWire 3.0.226 main/master. This version has a ton of great new features, improvements and optimizations, plus more than 100 issue fixes. This post takes an in-depth look at highlights from this great new version.
    Blog / 25 August 2023
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH