Laravel Composer package include - QueryPath - How to use it correctly with the framework

261 Views Asked by At

When adding the package QueryPath ( https://github.com/technosophos/querypath/ ) via Composer to Laravel, how do I use it correctly?

It has no namespace, and I can't use it out of the box.

Edit:

If you add that in your composer.json file, everything works out of the box:

  "files": [
    "vendor/querypath/querypath/src/QueryPath.php"
  ]
1

There are 1 best solutions below

0
BeS On BEST ANSWER

Looks like this package is not following the PSR-0 standard:

  • Each namespace must have a top-level namespace ("Vendor Name").

Loading the QueryPath in your composer.json class might solve the problem temporarily.

"autoload": {
    "classmap": [
        ...
    ],
    "psr-4": {
        ...
    },
    "files": ["vendor/technosophos/querypath/src/QueryPath.php"]
},