I tried running this command to install composer require yajra/laravel-datatables-oracle
and I saw the below message
Using version ^9.7 for yajra/laravel-datatables-oracle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
ErrorException : Invalid argument supplied for foreach()
at /var/www/atd-inspector/vendor/yajra/laravel-datatables-oracle/src/DataTablesServiceProvider.php:45
41| */
42| public function boot()
43| {
44| $engines = config('datatables.engines');
> 45| foreach ($engines as $engine => $class) {
46| $engine = Str::camel($engine);
47|
48| if (! method_exists(DataTables::class, $engine) && ! DataTables::hasMacro($engine)) {
49| DataTables::macro($engine, function () use ($class) {
Exception trace:
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError("Invalid argument supplied for foreach()", "/var/www/atd-inspector/vendor/yajra/laravel-datatables-oracle/src/DataTablesServiceProvider.php", [])
/var/www/atd-inspector/vendor/yajra/laravel-datatables-oracle/src/DataTablesServiceProvider.php:45
2 Yajra\DataTables\DataTablesServiceProvider::boot()
/var/www/atd-inspector/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:32
Please use the argument -v to see more details.
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Installation failed, reverting ./composer.json to its original content.
Are you upgrading or using a fresh install? Try removing the existing config if you already published.
Same for me. I'm using laravel with debug and test mode (not production) in localhost.
Any solution?
Thx.
I solved editing vendor/yajra/laravel-datatables-oracle/src/DataTablesServiceProvider.php
editing $engines to:
$engines = [
'eloquent' => Yajra\DataTables\Engines\EloquentEngine::class,
'query' => Yajra\DataTables\Engines\QueryBuilderEngine::class,
'collection' => Yajra\DataTables\Engines\CollectionEngine::class,
// add your custom engine
];
And then make the command again
composer require yajra/laravel-datatables-oracle:"~9.0"
Then you need to add in confi/app.php the two lines as sayed in the installation post and then run the command:
php artisan vendor:publish --provider=Yajra\DataTables\DataTablesServiceProvider
And
php artisan config:cache
And works !!
Having the same issue. Any fix to this one yet?
It seems like it is an issue with automatic package discovery in Laravel. If you copy the datatables.php config file into the config directory in Laravel and then run php artisan config:clear it works. Seems like the package discovery is running the boot method before the config file is available to provide the engines array.
@yajra is there any fix coming for this?
Was hoping to have a fix for this the past couple weeks. Editing /vendor
files with static content from a config file is a work-around, but not a fix.
Will review and try to replicate the issue.
Tried on fresh Laravel installation and works well.
> laravel new 2202
........
> composer require yajra/laravel-datatables-oracle
Using version ^9.7 for yajra/laravel-datatables-oracle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing yajra/laravel-datatables-oracle (v9.7.1): Loading from cache
yajra/laravel-datatables-oracle suggests installing yajra/laravel-datatables-buttons (Plugin for server-side exporting of dataTables.)
yajra/laravel-datatables-oracle suggests installing yajra/laravel-datatables-html (Plugin for server-side HTML builder of dataTables.)
yajra/laravel-datatables-oracle suggests installing yajra/laravel-datatables-fractal (Plugin for server-side response using Fractal.)
yajra/laravel-datatables-oracle suggests installing yajra/laravel-datatables-editor (Plugin to use DataTables Editor (requires a license).)
Writing lock file
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Discovered Package: facade/ignition
Discovered Package: fideloper/proxy
Discovered Package: laravel/tinker
Discovered Package: nesbot/carbon
Discovered Package: nunomaduro/collision
Discovered Package: yajra/laravel-datatables-oracle
Package manifest generated successfully.
Can anyone provide some steps to replicate this? Thanks!
Just did a fresh installation and I have the same issue.
Explicitly casting config('datatables.engines')
to an array seems to solve it cause its passing null
to the foreach
.
- $engines = config('datatables.engines');
+ $engines = (array) config('datatables.engines');
Same issue here, can't run any artisan commands or anything and the entire site has crashed with this error. Being able to replicate the issue shouldn't be necessary to provide a workaround like the one from @mtvbrianking, as this issue is preventing a clean deployment.
Please consider mitigating this issue even if you are unable to replicate it.
@filliph of course. The problem is it's hard for me to fix something that I can't replicate. A PR from
the community would be a big help for this.
@mtvbrianking would you mind sending a PR on how you fixed the issue?
It seems like it is an issue with automatic package discovery in Laravel. If you copy the datatables.php config file into the config directory in Laravel and then run php artisan config:clear it works. Seems like the package discovery is running the boot method before the config file is available to provide the engines array.
Thanks, ^_^
Most helpful comment
It seems like it is an issue with automatic package discovery in Laravel. If you copy the datatables.php config file into the config directory in Laravel and then run php artisan config:clear it works. Seems like the package discovery is running the boot method before the config file is available to provide the engines array.