Open specialtactics opened 4 years ago
Edit: All looks good now. The issue I had was my fault.
v3 of dingo/api is working fine. Thanks for updating it.
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
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.
Hi @specialtactics , I'm not doing anything than run
composer require dingo/api "^3.0"
I don't have any api.php config file.
It seems that Provider can't read formats from api.php config file of package.
@niskah-energies you need to copy/public that config file to your app/config directory, that is where it's meant to go.
@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;
}
Found solution, I'm delete manually all files in bootstrap/cache/ and run composer dumpautoload
.
Seems like in your cache your config was cached, and I guess it wasn't cleared for some reason when you installed dingo
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"