asvae / laravel-api-tester

Test your routes without hassle
http://laravel-api-tester.asva.by/
MIT License
354 stars 52 forks source link

Error while running `php artisan route:list` #50

Open craftisan opened 4 years ago

craftisan commented 4 years ago

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:

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.

gundamew commented 3 years ago

Same issue here. 😕

ldanielduarte commented 3 years ago

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

craftisan commented 3 years ago

@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

ldanielduarte commented 3 years ago

@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.

chintan-meek commented 3 years ago

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