skip to Main Content

I was working on php version 7.2 but now upgrading to 7.4 gave an issue while generating l5-swagger.
I read this stackoverflow qauestion which is not working for me.

php artisan l5-swagger:generate
Regenerating docs

   ErrorException  : Trying to access array offset on value of type bool

  at /home/smartmobe/Projects/defence-new/server/vendor/zircote/swagger-php/src/StaticAnalyser.php:37
    33|             if (empty($GLOBALS['swagger_opcache_warning'])) {
    34|                 $GLOBALS['swagger_opcache_warning'] = true;
    35|                 $status = opcache_get_status();
    36|                 $config = opcache_get_configuration();
  > 37|                 if ($status['opcache_enabled'] && $config['directives']['opcache.save_comments'] == false) {
    38|                     Logger::warning("php.ini "opcache.save_comments = 0" interferes with extracting annotations.n[LINK] http://php.net/manual/en/opcache.configuration.php#ini.opcache.save-comments");
    39|                 }
    40|             }
    41|         }

  Exception trace:

  1   IlluminateFoundationBootstrapHandleExceptions::handleError()
      /home/smartmobe/Projects/defence-new/server/vendor/zircote/swagger-php/src/StaticAnalyser.php:37

  2   SwaggerStaticAnalyser::fromFile()
      /home/smartmobe/Projects/defence-new/server/vendor/zircote/swagger-php/src/functions.php:41

  Please use the argument -v to see more details.

2

Answers


  1. zircote/swagger-php (the package in which your exception occurs) was updated to support PHP 7.4 in version 3.0.3. If you’re using Composer you can check the current version of the package in your project with composer info zircote/swagger-php and you can update it using composer update.

    If composer update doesn’t do the trick, you need to check that your composer.json allows for darkaonline/l5-swagger to have a version greater than 5.6.1 because it only started to support zircote/swagger-php:3.* from 5.6.2 upwards.

    Login or Signup to reply.
  2. For Laravel >= 8 and latest version of L5-Swagger you don’t need to extend the route you need to add the web middleware in the l5-swagger.php config file (documentations/defaults/routes/middleware/api);

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search