Yes, \Httpful\Request::get()
is valid PHP. It tells PHP that you're looking for the class Request
in the namespace Httpful
. More on namespaces: http://php.net/manual/en/language.namespaces.php
The reason you can call \Httpful\Request::get()
, but can't call Request::get()
is namespace related. In your index.php
, you're not defining a namespace. Therefor, PHP just looks for a class Request
in the global space (when calling Request::get()
). PHP does not check if there's a Request
class in another namespace.
You can use
(import) a class, that will prevent you from having to type the entire namespace everytime you want to use the Request
class:
<?php
use Httpful\Request;
$request = Request::get()
# you can also rename the class if you have multiple Request classes
use Httpful\Request as Banana;
$request = Banana::get()
More on that subject: http://php.net/manual/en/language.namespaces.importing.php