2

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

2
  • 1
    $test = \geoPHP::version(); Commented Mar 1, 2019 at 22:04
  • Thank you :) That worked Commented Mar 1, 2019 at 22:28

1 Answer 1

2

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.