laravel-api-tester icon indicating copy to clipboard operation
laravel-api-tester copied to clipboard

Error while running `php artisan route:list`

Open craftisan opened this issue 4 years ago • 5 comments

This is a follow up issue after fixing the route:cache problem mentioned in #42 If you fix that, please fix this also.

How to reproduce:

  • Follow the solution mentioned in #42
  • Run php artisan route:list

Error:

Array to string conversion
 
  at vendor/asvae/laravel-api-tester/src/Storages/JsonStorage.php:57
    53|         $this->files = $files;
    54|         $this->collection = $collection;
    55|         $path = explode('/', $path);
    56|         $this->filename = array_pop($path);
  > 57|         $this->path = implode('/'.$path);
    58|     }
    59|
    60|     /**
    61|      * Return path to folder that can contain file.

      +32 vendor frames
  33  [internal]:0
      Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))

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

Solution: It's really just silly mistake though, pardon me for all the drama above, just replace . with , in src/Storages/JsonStorage.php:

public function __construct(Filesystem $files, RequestCollection $collection, $path)
    {
        $this->files = $files;
        $this->collection = $collection;
        $path = explode('/', $path);
        $this->filename = array_pop($path);
        // Here was the mistake:
        $this->path = implode('/', $path);
    }

Also raising a PR for this. Quick fix.

craftisan avatar Sep 22 '20 17:09 craftisan

Same issue here. 😕

gundamew avatar Oct 30 '20 08:10 gundamew

Also need this fix. JsonStorage.php in line 57 - just change from . to ,

ldanielduarte avatar Feb 22 '21 11:02 ldanielduarte

@ldanielduarte @gundamew

I have created a forked version of this repo which works seamlessly with Laravel 7. You can install that if you are in need. I will be maintaining it on regular basis.

composer require craftisan/laravel-api-tester

craftisan avatar Feb 24 '21 17:02 craftisan

@craftisan I've noticed that before you answered and was already using it. It also have the fix in the route alias. I am using with Laravel 8.

ldanielduarte avatar Feb 24 '21 18:02 ldanielduarte

@craftisan I tried your package but it is not working on laravel 8.12

chintan-meek avatar Mar 12 '21 14:03 chintan-meek