Do in page.php
:
$client = new \PHPOnCouch\CouchClient ($URL, $DB);
or
use PHPOnCouch\CouchClient;
$client = new CouchClient ($URL, $DB);
this also works
use PHPOnCouch\CouchClient as SomeOtherFunnyName;
$client = new SomeOtherFunnyName ($URL, $DB);
and read more about namespaces
in php.
Little update to:
Shouldn't this page be connected to my config.php so that I don't have to put this in my page.php?
- Every include has its own local namesless namespace or one/more named namespaces!
- If no namespace is given, you have a namesless namespace.
In other word you can always use
namespace { /*code*/ }
in a php script
- If you are in a namespace , you have to include via
use
all needed classes.
And because all files have its own namespace, you have to include it via use
- The notation of namespaces in this way:
namespace xyz;
with no braces, is for files that holding only one namespace!
A simple exmaple (just one file):
namespace a {
class a {}
}
namespace b {
use a\a;
class b extends a{}
}
namespace {
use a\a;
use b\b;
new a;
new b;
}
lets say the last namespace isnt given, and we include this in an new file, we can do
namespace mynamespace;
use a\a;
use b\b as x;
new a;
new x;