phpinsights: Logic Exception unable to find data within Laravel project

Q A
Bug report? no
Feature request? no
Library version 2.0

HI I’m using php insights for the first time. I’ve installed the package within my Laravel project and published the config file.

On first run I get this error:

 LogicException 

  Unable to find data for /home/vagrant/code/wedleague/app/Http/Controllers/Admin/RoleController.php

  at vendor/nunomaduro/phpinsights/src/Domain/Runner.php:184
    180â–•     {
    181â–•         $cacheKey = 'insights.' . $this->cacheKey . '.' . md5($file->getContents());
    182â–•         // Do not use cache if fix is enabled to force processors to handle it
    183â–•         if (! $this->cache->has($cacheKey)) {
  ➜ 184▕             throw new \LogicException('Unable to find data for ' . $file->getPathname());
    185â–•         }
    186â–• 
    187â–•         $this->loadDetailsCache($cacheKey);
    188â–• 

      +4 vendor frames 
  5   [internal]:0
      NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory::NunoMaduro\PhpInsights\Domain\Insights\{closure}()

      +17 vendor frames 
  23  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

I’m not sure where to start working out what’s gone wrong. The controller exists - what does this error mean?

Sorry for vague question.

Running on a vagrant machine with homestead php7.4 if that’s any help.

Any pointers appreciated

Thank you

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 27 (5 by maintainers)

Most upvoted comments

I still have this problem with friendsofphp/php-cs-fixer at v3.10.0 and PHPInsights at "v2.4.0

php artisan insights  --flush-cache

 848/848 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

   LogicException

  Unable to find data for /***/routes/auth.php

  at vendor/nunomaduro/phpinsights/src/Domain/Runner.php:184
    180▕     {
    181▕         $cacheKey = 'insights.' . $this->cacheKey . '.' . md5($file->getContents());
    182▕         // Do not use cache if fix is enabled to force processors to handle it
    183▕         if (! $this->cache->has($cacheKey)) {
  ➜ 184▕             throw new \LogicException('Unable to find data for ' . $file->getPathname());
    185▕         }
    186▕
    187▕         $this->loadDetailsCache($cacheKey);
    188▕

      +4 vendor frames
  5   [internal]:0
      NunoMaduro\PhpInsights\Domain\Insights\InsightCollectionFactory::NunoMaduro\PhpInsights\Domain\Insights\{closure}("PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\UnnecessaryFinalModifierSniff")

      +17 vendor frames
  23  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

Pinning friendsofphp/php-cs-fixer at 3.9.5 worked for me as a temporary solution. 3.9.6 and 3.10.0 are both giving the error

I also confirm that pinning friendsofphp/php-cs-fixer at 3.9.5 solves the problem.

In my case it’s because some files are in Windows mode (crlf) not linux (lf). I applyed a dos2unix command to fix the error

Still experiencing this issue. None of the above solutions worked for me. Ended up just commenting out lines 183 - 185 in vendor/nunomaduro/phpinsights/src/Domain/Runner.php to allow for the report to be fully generated.

// if (! $this->cache->has($cacheKey)) {
//     throw new \LogicException('Unable to find data for ' . $file->getPathname().'. $file='.var_export($file, true). ':: $cacheKey='.var_export($cacheKey, true).' :: $this->cacheKey='.$this->cacheKey.' :: $file->getContents()='.$file->getContents());
// }

I get the same error no matter which file im checking - on laravel and php 8, also in new Project…

php artisan insights config\app.php

 3/3 [============================] 100%

   LogicException 

  Unable to find data for F:\xampp\htdocs\ima-api\config\app.php

  at F:\xampp\htdocs\ima-api\vendor\nunomaduro\phpinsights\src\Domain\Runner.php:184
    180▕     {
    181▕         $cacheKey = 'insights.' . $this->cacheKey . '.' . md5($file->getContents());
    182▕         // Do not use cache if fix is enabled to force processors to handle it
    183▕         if (! $this->cache->has($cacheKey)) {
  ➜ 184▕             throw new \LogicException('Unable to find data for ' . $file->getPathname());
    185▕         }
    186▕
    187▕         $this->loadDetailsCache($cacheKey);
    188▕

  1   F:\xampp\htdocs\ima-api\vendor\nunomaduro\phpinsights\src\Domain\Runner.php:170
      NunoMaduro\PhpInsights\Domain\Runner::processFile(Object(Symfony\Component\Finder\SplFileInfo))

  2   F:\xampp\htdocs\ima-api\vendor\nunomaduro\phpinsights\src\Domain\Insights\InsightFactory.php:98
      NunoMaduro\PhpInsights\Domain\Runner::run()

got it… so we’ll be waiting till next commit to be fixed!