Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

knubbe's avatar
Level 36

Laravel & Swagger is not working

I just install:

  • zircote/swagger-php and
  • darkaonline/l5-swagger but it's impossible to publish configuration and there is no artisan command for generating documantation. Does anyone have a clue and some alternative for laravel 11?
0 likes
2 replies
LaryAI's avatar
Level 58

To resolve the issue with darkaonline/l5-swagger in Laravel, especially if you're unable to publish the configuration or find the artisan command for generating documentation, follow these steps:

  1. Install the Package:

    First, ensure that you have installed the package correctly. Run the following command to install darkaonline/l5-swagger:

    composer require "darkaonline/l5-swagger"
    
  2. Publish the Configuration:

    After installation, you need to publish the configuration files. Use the following artisan command:

    php artisan vendor:publish --provider="L5Swagger\L5SwaggerServiceProvider"
    

    This command should publish the configuration file to config/l5-swagger.php.

  3. Check the Configuration:

    Open the config/l5-swagger.php file and ensure that the settings match your application's requirements. You might need to adjust paths or other settings based on your project structure.

  4. Generate Documentation:

    To generate the Swagger documentation, use the following artisan command:

    php artisan l5-swagger:generate
    

    This command will scan your project for annotations and generate the Swagger documentation.

  5. Access the Documentation:

    By default, you can access the Swagger UI at http://your-app-url/api/documentation. Ensure your web server is running and that there are no routing conflicts.

  6. Troubleshooting:

    • If the commands are not available, double-check that the service provider is correctly registered in your config/app.php file. However, with Laravel's package auto-discovery, this should be handled automatically.
    • Ensure that your PHP version and Laravel version are compatible with the package version you are using.
  7. Alternative Solutions:

    If you continue to face issues, consider using alternative packages like swagger-lume or laravel-openapi. These packages also provide Swagger/OpenAPI documentation generation for Laravel applications.

By following these steps, you should be able to set up and use Swagger with Laravel successfully. If you encounter specific errors, please provide the error messages for more targeted assistance.

knubbe's avatar
Level 36

@LaryAI For publishing configuration I get No publishable resources for tag [] and for running a command I get There are no commands defined in the "l5-swagger" namespace

Please or to participate in this conversation.