title: Laravel upgrade from 5.8 to 7 - Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
body: <p>I'm trying to upgrade Laravel from 5.8 to 7.*. I have changed the <code>[composer.json][1]</code> file (copied from official Laravel GitHub repository) since I have no third-party dependencies in my project. However, when I run <code>composer update</code> command it outputs the following error.</p>
  <p><a href="https://i.stack.imgur.com/dT5P7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dT5P7.png" alt="enter image description here" /></a></p>
  <p>Here is my updated <code>composer.json</code> file.</p>
  <pre><code>{
      &quot;name&quot;: &quot;laravel/laravel&quot;,
      &quot;type&quot;: &quot;project&quot;,
      &quot;description&quot;: &quot;The Laravel Framework.&quot;,
      &quot;keywords&quot;: [
          &quot;framework&quot;,
          &quot;laravel&quot;
      ],
      &quot;license&quot;: &quot;MIT&quot;,
      &quot;require&quot;: {
          &quot;php&quot;: &quot;^7.2.5&quot;,
          &quot;fideloper/proxy&quot;: &quot;^4.2&quot;,
          &quot;fruitcake/laravel-cors&quot;: &quot;^2.0&quot;,
          &quot;guzzlehttp/guzzle&quot;: &quot;^6.3&quot;,
          &quot;laravel/framework&quot;: &quot;^7.22.2&quot;,
          &quot;laravel/tinker&quot;: &quot;^2.0&quot;
      },
      &quot;require-dev&quot;: {
          &quot;facade/ignition&quot;: &quot;^2.0&quot;,
          &quot;fzaninotto/faker&quot;: &quot;^1.9.1&quot;,
          &quot;mockery/mockery&quot;: &quot;^1.3.1&quot;,
          &quot;nunomaduro/collision&quot;: &quot;^4.1&quot;,
          &quot;phpunit/phpunit&quot;: &quot;^8.5&quot;
      },
      &quot;config&quot;: {
          &quot;optimize-autoloader&quot;: true,
          &quot;preferred-install&quot;: &quot;dist&quot;,
          &quot;sort-packages&quot;: true
      },
      &quot;extra&quot;: {
          &quot;laravel&quot;: {
              &quot;dont-discover&quot;: [
                  
              ]
          }
      },
      &quot;autoload&quot;: {
          &quot;psr-4&quot;: {
              &quot;App\\&quot;: &quot;app/&quot;
          },
          &quot;classmap&quot;: [
              &quot;database/seeds&quot;,
              &quot;database/factories&quot;
          ]
      },
      &quot;autoload-dev&quot;: {
          &quot;psr-4&quot;: {
              &quot;App\\&quot;: &quot;app/&quot;
          }
      },
      &quot;minimum-stability&quot;: &quot;dev&quot;,
      &quot;prefer-stable&quot;: true,
      &quot;scripts&quot;: {
          &quot;post-autoload-dump&quot;: [
              &quot;Illuminate\\Foundation\\ComposerScripts::postAutoloadDump&quot;,
              &quot;@php artisan package:discover --ansi&quot;
          ],
          &quot;post-root-package-install&quot;: [
              &quot;@php -r \&quot;file_exists('.env') || copy('.env.example', '.env');\&quot;&quot;
          ],
          &quot;post-create-project-cmd&quot;: [
              &quot;@php artisan key:generate --ansi&quot;
          ]
      }
  }
  </code></pre>
  <p>Here is my old <code>composer.json</code> file for Laravel 5.8.</p>
  <pre><code>{
      &quot;name&quot;: &quot;laravel/laravel&quot;,
      &quot;type&quot;: &quot;project&quot;,
      &quot;description&quot;: &quot;The Laravel Framework.&quot;,
      &quot;keywords&quot;: [
          &quot;framework&quot;,
          &quot;laravel&quot;
      ],
      &quot;license&quot;: &quot;MIT&quot;,
      &quot;require&quot;: {
          &quot;php&quot;: &quot;^7.1.3&quot;,
          &quot;fideloper/proxy&quot;: &quot;^4.0&quot;,
          &quot;laravel/framework&quot;: &quot;5.8.*&quot;,
          &quot;laravel/tinker&quot;: &quot;^1.0&quot;,
          &quot;yoeunes/toastr&quot;: &quot;^1.2&quot;
      },
      &quot;require-dev&quot;: {
          &quot;beyondcode/laravel-dump-server&quot;: &quot;^1.0&quot;,
          &quot;filp/whoops&quot;: &quot;^2.0&quot;,
          &quot;fzaninotto/faker&quot;: &quot;^1.4&quot;,
          &quot;mockery/mockery&quot;: &quot;^1.0&quot;,
          &quot;nunomaduro/collision&quot;: &quot;^2.0&quot;,
          &quot;phpunit/phpunit&quot;: &quot;^7.5&quot;
      },
      &quot;config&quot;: {
          &quot;optimize-autoloader&quot;: true,
          &quot;preferred-install&quot;: &quot;dist&quot;,
          &quot;sort-packages&quot;: true
      },
      &quot;extra&quot;: {
          &quot;laravel&quot;: {
              &quot;dont-discover&quot;: []
          }
      },
      &quot;autoload&quot;: {
          &quot;psr-4&quot;: {
              &quot;skillTool\\&quot;: &quot;app/&quot;
          },
          &quot;classmap&quot;: [
              &quot;database/seeds&quot;,
              &quot;database/factories&quot;
          ]
      },
      &quot;autoload-dev&quot;: {
          &quot;psr-4&quot;: {
              &quot;Tests\\&quot;: &quot;tests/&quot;
          }
      },
      &quot;minimum-stability&quot;: &quot;dev&quot;,
      &quot;prefer-stable&quot;: true,
      &quot;scripts&quot;: {
          &quot;post-autoload-dump&quot;: [
              &quot;Illuminate\\Foundation\\ComposerScripts::postAutoloadDump&quot;,
              &quot;@php artisan package:discover --ansi&quot;
          ],
          &quot;post-root-package-install&quot;: [
              &quot;@php -r \&quot;file_exists('.env') || copy('.env.example', '.env');\&quot;&quot;
          ],
          &quot;post-create-project-cmd&quot;: [
              &quot;@php artisan key:generate --ansi&quot;
          ]
      }
  }
  </code></pre>
  <p>Additionally, I have changed the <code>Exceptions/Handler.php</code> to reflect Laravel 7 changes.</p>
  <pre><code>&lt;?php
  
  namespace App\Exceptions;
  
  use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
  use Throwable;
  
  class Handler extends ExceptionHandler
  {
      /**
       * A list of the exception types that are not reported.
       *
       * @var array
       */
      protected $dontReport = [
          //
      ];
  
  /**
   * A list of the inputs that are never flashed for validation exceptions.
   *
   * @var array
   */
  protected $dontFlash = [
      'password',
      'password_confirmation',
  ];
  
  /**
   * Report or log an exception.
   *
   * @param  \Throwable  $exception
   * @return void
   *
   * @throws \Exception
   */
  public function report(Throwable $exception)
  {
      parent::report($exception);
  }
  
  /**
   * Render an exception into an HTTP response.
   *
   * @param  \Illuminate\Http\Request  $request
   * @param  \Throwable  $exception
   * @return \Symfony\Component\HttpFoundation\Response
   *
   * @throws \Throwable
   */
  public function render($request, Throwable $exception)
  {
      return parent::render($request, $exception);
  }
  }
  </code></pre>
  <p>I have changed the <code>sessions.php</code> as follows.</p>
  <pre><code>'secure' =&gt; env('SESSION_SECURE_COOKIE', null),
  </code></pre>
  <p>I tried to clear the cache. It yields an error as well.</p>
  <p><a href="https://i.stack.imgur.com/CFOCh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CFOCh.png" alt="enter image description here" /></a></p>
  <p>The error says that Kernal.php does not exist. However, the Kernal.php file exists in the Console folder.</p>
  <pre><code>&lt;?php
  
  namespace skillTool\Console;
  
  use Illuminate\Console\Scheduling\Schedule;
  use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
  
  class Kernel extends ConsoleKernel
  {
      /**
       * The Artisan commands provided by your application.
       *
       * @var array
       */
      protected $commands = [
          //
      ];
  
      /**
       * Define the application's command schedule.
       *
       * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
       * @return void
       */
      protected function schedule(Schedule $schedule)
      {
          // $schedule-&gt;command('inspire')
          //          -&gt;hourly();
      }
  
      /**
       * Register the commands for the application.
       *
       * @return void
       */
      protected function commands()
      {
          $this-&gt;load(__DIR__.'/Commands');
  
          require base_path('routes/console.php');
      }
  }
  </code></pre>