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 telescope local-only + default config = error Class "Laravel\Telescope\TelescopeApplicationServiceProvider" not found #535

Open
dvdheiden opened this issue Mar 25, 2023 · 1 comment

Comments

@dvdheiden
Copy link

dvdheiden commented Mar 25, 2023

  • L5-Swagger Version: 8.5.0
  • PHP Version: 8.1.17
  • OS: MacOS

Description:

Not completely an issue of this package, but the combination of Laravel Telescope in local-only mode (see: https://laravel.com/docs/9.x/telescope#local-only-installation) and the default config of this package could result an error when generating the docs:

In TelescopeServiceProvider.php line 10:
                                                                           
  [Error]                                                                  
  Class "Laravel\Telescope\TelescopeApplicationServiceProvider" not found  

Steps To Reproduce:

  1. Install Laravel.
  2. Install Laravel Telescope in local only mode.
  3. Install this package ❤️ .
  4. Run composer install --no-dev to exclude development packages.
  5. Set app to any other environment than local in your .env.
  6. Run the command: l5-swagger:generate and see error.

Cause

When running Laravel Telescope in local only mode, the package won't be installed on any other environment than local. The TelescopeServiceProvider won't be loaded, but still extends a non-existing class (from the Laravel Telescope package). The error occurs because the default config of this package scans the whole app folder, so also this service provider.

Possible solution

A few possible solutions might be:

  • Exclude service providers:
/*
 * Absolute path to directories that should be exclude from scanning
 */
 'excludes' => [
    base_path('app/Providers'),
],
  • Default to the paths:
/*
 * Absolute paths to directory containing the swagger annotations are stored.
 */
 'annotations' => [
     base_path('app/Http'),
     base_path('app/Models'),
 ],
  • Let users configure this themselves in their custom config (which I did to solve this issue). Might be worth mentioning in the docs.

I am uncertain if this package should do anything about this, but at least this issue might help some (and probably my future self) with solving that error.

@Astriel
Copy link

Astriel commented Oct 11, 2024

Facing this problem on production too. I had to generate the doc on my localhost then push it to the production server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants