Eddy
Eddy

Reputation: 145

Laravel 5.4 - Access Static Method inside Controller Method

in my Laravel controller, I am trying to access a static method on a 3rd party library from a method inside the controller, but I always get the error:

"Fatal error: Class 'App\Http\Controllers\geoPHP' not found".

While on a breakpoint using VS Code, I can use the terminal and access the static method. Thoughts?

In the controller, I have the method to just get the version of the static class software:

public function parseKMLFile() {
    $test = geoPHP::version();
}

In composer, in the autoload section, I have:

"autoload": {
     "psr-4": {
         "App\\": "app/"
     },
      "files": [
          "app/Library/geoPHP/geoPHP.inc",
          "app/Library/gpointconverter.class.php",
          "app/Library/gpoint.php"
       ]
},

Thanks in advance

Upvotes: 2

Views: 562

Answers (1)

dparoli
dparoli

Reputation: 9161

You have to be careful with namespace convention, in the controller you are in the App\Http\Controllers\ namespace, so if you want to call your custom class you have to explicit escape the controller namespace, i.e:

$test = \geoPHP::version();

Upvotes: 2

Related Questions