Search code examples
laravelpackagecomposer-phpquerypath

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


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"
  ]

Solution

  • 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"]
    },