Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel 7 testing - use this package with Laravel 7 #1721

Open
specialtactics opened this issue Mar 13, 2020 · 9 comments
Open

Laravel 7 testing - use this package with Laravel 7 #1721

specialtactics opened this issue Mar 13, 2020 · 9 comments

Comments

@specialtactics
Copy link
Member

If you are in a position to upgrade to Laravel 7, please try v3.0.0-rc2 of this package, and report back any issues. These are pre-release versions, so I wouldn't recommend running them in production.

You can do this in composer with the requirement "^3.0"

@bbashy
Copy link

bbashy commented Mar 14, 2020

Edit: All looks good now. The issue I had was my fault.

v3 of dingo/api is working fine. Thanks for updating it.

@niskah-energies
Copy link

niskah-energies commented Apr 4, 2020

Hi,

Failling to install to Laravel 7:

composer require dingo/api "^3.0"


./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 0 updates, 0 removals
  - Installing league/fractal (0.19.2): Loading from cache
  - Installing doctrine/annotations (1.10.1): Loading from cache
  - Installing dingo/blueprint (v0.4.1): Loading from cache
  - Installing dingo/api (v3.0.0): Loading from cache
league/fractal suggests installing pagerfanta/pagerfanta (Pagerfanta Paginator)
league/fractal suggests installing zendframework/zend-paginator (Zend Framework Paginator)
dingo/api suggests installing tymon/jwt-auth (Protect your API with JSON Web Tokens.)
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   TypeError 

  Argument 1 passed to Dingo\Api\Http\Response::setFormatters() must be of the type array, null given, called in /Users/xxx/Documents/www/xxx-spa/backend/vendor/dingo/api/src/Provider/DingoServiceProvider.php on line 34

  at vendor/dingo/api/src/Http/Response.php:263
    259|      * @param array $formatters
    260|      *
    261|      * @return void
    262|      */
  > 263|     public static function setFormatters(array $formatters)
    264|     {
    265|         static::$formatters = $formatters;
    266|     }
    267|

      +11 vendor frames 
  12  [internal]:0
      Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Dingo\Api\Provider\LaravelServiceProvider))

      +5 vendor frames 
  18  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

@specialtactics
Copy link
Member Author

Hi @niskah-energies - you haven't got you api.php config set up correctly, specifically the "formats" key, please check the wiki instructions for installation. Make sure you public vendor configs if installing for the first time.

@niskah-energies
Copy link

Hi @specialtactics , I'm not doing anything than run

composer require dingo/api "^3.0"

I don't have any api.php config file.

@niskah-energies
Copy link

It seems that Provider can't read formats from api.php config file of package.

@specialtactics
Copy link
Member Author

@niskah-energies you need to copy/public that config file to your app/config directory, that is where it's meant to go.

@niskah-energies
Copy link

niskah-energies commented Apr 5, 2020

@specialtactics I'm copied vendor/dingo/config/api.php file to config/api.php but it doesn't work.
Provider don't read config key.

@niskah-energies you need to copy/public that config file to your app/config directory, that is where it's meant to go.

Normally api.php config file is copied when we run php artisan vendor:publish --provider="Dingo\Api\Provider\LaravelServiceProvider" command.

/dingo/api/provider/ServiceProvider.php

protected function config($item, $instantiate = true)
    {
        $value = $this->app['config']->get('api.'.$item);
        dd('value='.$value); <==== returns null
        if (is_array($value)) {
            return $instantiate ? $this->instantiateConfigValues($item, $value) : $value;
        }

        return $instantiate ? $this->instantiateConfigValue($item, $value) : $value;
    }

@niskah-energies
Copy link

Found solution, I'm delete manually all files in bootstrap/cache/ and run composer dumpautoload .

@specialtactics
Copy link
Member Author

Seems like in your cache your config was cached, and I guess it wasn't cleared for some reason when you installed dingo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants