Why are "use" statements not working in my PHP scripts?

I'm coming back to PHP after many years and am running into a bit of an odd problem. I'm running PHP 7.1.7 on Windows and am trying to install and utilize the maclof/kubernetes-client library via Composer. I have the following simple code snippet to test things out:
<?php
require __DIR__ . '/vendor/autoload.php';
use Maclof\Kubernetes\Client;
$path = realpath(__DIR__ . '/kubeconfig.yaml');
// this works (when fully qualified)
$config = Maclof\Kubernetes\Client::parseKubeconfigFile($path);
// but this doesn't
$client = new Client($config);
?>
As you can see, when I access the static methodparseKubeconfigFile
using the fully-qualified class name (Maclof\Kubernetes\Client
), this works. But when I try to just use the shorter name ofClient
, it doesn't work. Evenclass_exists("Client")
returns false. It's as though PHP is outright ignoring theuse
statement, and I don't know why.
What am I missing? Is there some weird php.ini directive that governsuse
statements? Or is there some wacky bug in this specific version of PHP? I'm pulling my hair out right now trying to understand why this doesn't work.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: call to a member function update() on null
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.