laravel-permission: ErrorException : Trying to access array offset on value of type null. On fresh laravel installation.
I can’t install the package on my recent laravel project. It works fine on the previous ones. Here is the error I get
`composer require spatie/laravel-permission Using version ^3.6 for spatie/laravel-permission ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 1 install, 0 updates, 1 removal
- Removing spatie/laravel-view-components (1.2.0)
- Installing spatie/laravel-permission (3.6.0): Loading from cache Writing lock file Generating optimized autoload files
Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi
ErrorException : Trying to access array offset on value of type null
at /home/abdellah/Documents/PROJECTS/Bank/vendor/spatie/laravel-permission/src/PermissionServiceProvider.php:61 57| protected function registerModelBindings() 58| { 59| $config = $this->app->config[‘permission.models’]; 60|
61| $this->app->bind(PermissionContract::class, $config[‘permission’]); 62| $this->app->bind(RoleContract::class, $config[‘role’]); 63| } 64| 65| protected function registerBladeExtensions()
Exception trace:
1 Illuminate\Foundation\Bootstrap\HandleExceptions::handleError() /home/abdellah/Documents/PROJECTS/Bank/vendor/spatie/laravel-permission/src/PermissionServiceProvider.php:61
2 Spatie\Permission\PermissionServiceProvider::registerModelBindings() /home/abdellah/Documents/PROJECTS/Bank/vendor/spatie/laravel-permission/src/PermissionServiceProvider.php:36
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.`
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 29
Links to this issue
Commits related to this issue
- Avoid odd config merge issue from #1370 Really not sure what environmental condition is causing this to be needed suddenly. Need more details to reproduce the problem consistently in order to find a ... — committed to spatie/laravel-permission by drbyte 4 years ago
- Avoid config merge issue from #1370 — committed to spatie/laravel-permission by drbyte 4 years ago
- Avoid odd config merge issue from #1370 Really not sure what environmental condition is causing this to be needed suddenly. Need more details to reproduce the problem consistently in order to find a ... — committed to ThanhSonITNIC/laravel-permission by drbyte 4 years ago
- Avoid config merge issue from #1370 — committed to ThanhSonITNIC/laravel-permission by drbyte 4 years ago
- Remind devs not to cache config in development Published configs can't be accessed if config is cached. Don't cache in development environment! Fixes #1464 Ref #1411 Ref #1370 — committed to spatie/laravel-permission by drbyte 4 years ago
Solution:
php artisan config:clear
or
sail artisan config:clear
I don’t have the permission.php file in the config folder.
it’s 7.4.2, runs on both 7.4.1 and 7.4.3
Strange.
What’s different between your environment and mine? (I’m using Valet 2.8.1, with latest
composer self-update
, latestcomposer global update
, and latestbrew upgrade
, all updated this morning)Thanks for posting back. I’m glad you found where the problem was! 👍