Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel autodiscovery #38

Open
wedi opened this issue Aug 25, 2021 · 2 comments
Open

Laravel autodiscovery #38

wedi opened this issue Aug 25, 2021 · 2 comments
Labels
enhancement New feature or request verification
Milestone

Comments

@wedi
Copy link

wedi commented Aug 25, 2021

Is it somehow possible to support Laravels autodicovery feature?

I tried to dig into Laravel to find the relevant code but I only found the place where the extra gets loaded, not where it's actually stored.

Php version:

8.0 (but doesn't really matter)

Os:

macOS / Ubunutu / Alpine

Composer packages with detection troubles:

All Laravel autodiscovered packages, e.g. https://github.com/spatie/laravel-json-api-paginate

Which type of autoload it uses?

Autodiscovery via the package's composer.json extra.
See: https://laravelpackage.com/03-service-providers.html#autoloading

composer.json of the package that is not detected:

{
  ...,

  "autoload": { ... },

  "extra": {
      "laravel": {
          "providers": [
              "JohnDoe\\BlogPackage\\BlogPackageServiceProvider"
          ]
      }
  }
}

Code example of package classes usage that not detected:

The methods are magically injected, you call the package methods on your own models without any use.

YourModel::jsonPaginate();

See: https://github.com/spatie/laravel-json-api-paginate#usage

@Insolita
Copy link
Owner

Thanks for report, will check it

@Insolita Insolita added enhancement New feature or request verification labels Aug 25, 2021
@Insolita Insolita added this to the 2.4.0 milestone Aug 25, 2021
@Levivb
Copy link

Levivb commented Aug 3, 2022

Laravel reads the vendor/composer/installed.json. You could check the "extra": { "laravel": { "providers": [ of all packages listed there.
Keep in mind that the root composer.json could also contain excludes for packages from autoloading:

"extra": {
        "laravel": {
            "dont-discover": [

which are then not autoload anymore.

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request verification
Projects
None yet
Development

No branches or pull requests

3 participants