As a standard answer, check your PHP version. The documentation for RuntimeException
requires at least PHP 5.1 or higher.
You may do this via phpinfo()
, or php -v
in your console (if you are running it locally and have access to php via. PATH)
Edit: This question and answer seem related. Essentially, it is also your namespace causing the mixup. Essentially, it is looking for a namespaced RuntimeException class (see your error).
Since you're using namespaces, you will need to reference back to the root namespace (\
) any time you want to use the native classes.
You may want to try:
throw new \RuntimeException('...'); // The '\' tells PHP to use the root namespace.
Second Edit:
As for your second issue, that is a matter of your code order.
In your CallerNS.php
file, you're declaring to use the namespace Pack\sp
, and then including your namespaced files into your code. This won't work because you will need to have the namespace already declared before you can use it.
You can either include the files first, or use \Pack\sp\Funct0(...)
instead.