Skip to content

Instantly share code, notes, and snippets.

@dongilbert
Created November 28, 2012 16:38
Show Gist options
  • Select an option

  • Save dongilbert/4162419 to your computer and use it in GitHub Desktop.

Select an option

Save dongilbert/4162419 to your computer and use it in GitHub Desktop.
Joomla Namespace Example
<?php // File: index.php
const JPATH_BASE = __DIR__;
require_once JPATH_BASE . '/libraries/joomla/loader.php';
Joomla\Loader::registerNamespace('Joomla', JPATH_BASE . '/libraries/joomla');
Joomla\Application\Web::getInstance('\\Joomla\\Application\\Web')->execute();
<?php // File: libraries/joomla/application/base.php
namespace Joomla\Application;
class Base {}
<?php // File: libraries/joomla/application/web.php
namespace Joomla\Application;
// Here we extend Base, because we are in the same namespace.
class Web extends Base {}
<?php // File: libraries/joomla/controller/base.php
namespace Joomla\Controller;
// We simply extend Controller, since we are in the same namespace.
class Base extends Controller {}
<?php // File: libraries/joomla/controller/controller.php
namespace Joomla\Controller;
// This extends Serializable from the Global Namespace
class Controller extends \Serializable {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment