skip to Main Content

I have a error in laravel

ErrorException: Trying to access array offset on value of type null

i use php 7.4 and I get the following error

Next ErrorException: Trying to access array offset on value of type null (View: /var/www/html/resources/views/admin/install/steps.blade.php) (View: /var/www/html/resources/views/admin/install/steps.blade.php) (View: /var/www/html/resources/views/admin/install/steps.blade.php) in /var/www/html/storage/framework/views/2d3a44bc043a42321af3d3eaee6ab680:23
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(44): IlluminateViewEnginesCompilerEngine->handleViewException()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(58): IlluminateViewEnginesPhpEngine->evaluatePath()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(147): IlluminateViewEnginesCompilerEngine->get()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(118): IlluminateViewView->getContents()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/View/View.php(83): IlluminateViewView->renderContents()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Response.php(51): IlluminateViewView->render()
#6 /var/www/html/vendor/symfony/http-foundation/Response.php(202): IlluminateHttpResponse->setContent()
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1229): SymfonyComponentHttpFoundationResponse->__construct()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(112): IlluminateRoutingRouter->prepareResponse()
#9 [internal function]: IlluminateRoutingControllerDispatcher->IlluminateRouting{closure}()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#11 [internal function]: IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(114): IlluminatePipelinePipeline->then()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(68): IlluminateRoutingControllerDispatcher->callWithinStack()
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(203): IlluminateRoutingControllerDispatcher->dispatch()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(134): IlluminateRoutingRoute->runWithCustomDispatcher()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(708): IlluminateRoutingRoute->run()
#18 [internal function]: IlluminateRoutingRouter->IlluminateRouting{closure}()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#20 /var/www/html/app/Http/Middleware/IsInstalled.php(23): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#21 [internal function]: AppHttpMiddlewareIsInstalled->handle()
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#23 [internal function]: IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(710): IlluminatePipelinePipeline->then()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(674): IlluminateRoutingRouter->runRouteWithinStack()
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): IlluminateRoutingRouter->dispatchToRoute()
#28 /var/www/html/bootstrap/cache/compiled.php(2310): IlluminateRoutingRouter->dispatch()
#29 [internal function]: IlluminateFoundationHttpKernel->IlluminateFoundationHttp{closure}()
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(139): call_user_func()
#31 /var/www/html/app/Http/Middleware/SetLanguage.php(35): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#32 [internal function]: AppHttpMiddlewareSetLanguage->handle()
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#34 /var/www/html/app/Http/Middleware/EmptyCharacterIfServerOffline.php(25): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#35 [internal function]: AppHttpMiddlewareEmptyCharacterIfServerOffline->handle()
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#37 /var/www/html/app/Http/Middleware/ApplicationEnabled.php(36): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#38 [internal function]: AppHttpMiddlewareApplicationEnabled->handle()
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#40 /var/www/html/app/Http/Middleware/NotInstalled.php(23): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#41 [internal function]: AppHttpMiddlewareNotInstalled->handle()
#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#43 /var/www/html/bootstrap/cache/compiled.php(2925): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#44 [internal function]: IlluminateFoundationHttpMiddlewareVerifyCsrfToken->handle()
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#46 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#47 [internal function]: IlluminateViewMiddlewareShareErrorsFromSession->handle()
#48 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#49 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#50 [internal function]: IlluminateSessionMiddlewareStartSession->handle()
#51 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#52 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#53 [internal function]: IlluminateCookieMiddlewareAddQueuedCookiesToResponse->handle()
#54 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#55 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#56 [internal function]: IlluminateCookieMiddlewareEncryptCookies->handle()
#57 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#58 /var/www/html/bootstrap/cache/compiled.php(2982): IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#59 [internal function]: IlluminateFoundationHttpMiddlewareCheckForMaintenanceMode->handle()
#60 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(124): call_user_func_array()
#61 [internal function]: IlluminatePipelinePipeline->IlluminatePipeline{closure}()
#62 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): call_user_func()
#63 /var/www/html/bootstrap/cache/compiled.php(2257): IlluminatePipelinePipeline->then()
#64 /var/www/html/bootstrap/cache/compiled.php(2240): IlluminateFoundationHttpKernel->sendRequestThroughRouter()
#65 /var/www/html/public/index.php(53): IlluminateFoundationHttpKernel->handle()
#66 {main}  

in steps.blade.php is like this :

<div class="mt-element-step">
    <div class="row step-line">
        <div class="col-md-4 mt-step-col first {{ isDone( 'admin.installer.welcome' ) . isActive( 'admin.installer.welcome' ) }}">
            <div class="mt-step-number bg-white">1</div>
            <div class="mt-step-title uppercase font-grey-cascade">{{ trans( 'install.welcome.title' ) }}</div>
        </div>
        <div class="col-md-4 mt-step-col {{ isDone( 'admin.installer.settings' ) . isActive( 'admin.installer.settings' ) }}">
            <div class="mt-step-number bg-white">2</div>
            <div class="mt-step-title uppercase font-grey-cascade">{{ trans( 'install.settings.title' ) }}</div>
        </div>
        <!--<div class="col-md-2 mt-step-col {{ isDone( 'admin.installer.environment' ) . isActive( 'admin.installer.environment' ) }}">
            <div class="mt-step-number bg-white">2</div>
            <div class="mt-step-title uppercase font-grey-cascade">{{ trans( 'install.environment.title' ) }}</div>
        </div>
        <div class="col-md-2 mt-step-col {{ isDone( 'admin.installer.requirements' ) . isActive( 'admin.installer.requirements' ) }}">
            <div class="mt-step-number bg-white">3</div>
            <div class="mt-step-title uppercase font-grey-cascade">{{ trans( 'install.requirements.title' ) }}</div>
        </div>
        <div class="col-md-2 mt-step-col {{ isDone( 'admin.installer.permissions' ) . isActive( 'admin.installer.permissions' ) }}">
            <div class="mt-step-number bg-white">4</div>
            <div class="mt-step-title uppercase font-grey-cascade">{{ trans( 'install.permissions.title' ) }}</div>
        </div> -->
        <div class="col-md-4 mt-step-col last {{ ( session( 'message' )['status'] === 'success' ) ? 'done' : NULL . isActive( 'admin.installer.complete' ) }}">
            <div class="mt-step-number bg-white">3</div>
            <div class="mt-step-title uppercase font-grey-cascade">{{ trans( 'install.complete.title' ) }}</div>
        </div>
    </div>
</div>





how i fix it?

I keep getting the error when trying to use the project in composer Whoops, looks like something went wrong.

there is some problem in the new version of php but I don’t know how to update these lines

2

Answers


  1. session( 'message' ) is null so when you use session( 'message' )['status'] === 'success' you get that error.

    Verify the array exists before using it

    <div class="col-md-4 mt-step-col last {{ ((session('message')['status'] ?? '') === 'success') ? 'done' : '' . isActive( 'admin.installer.complete' ) }}">
    
    Login or Signup to reply.
  2. You could also use the native ‘dot’ notation to retrieve the ‘status’ element from ‘message’ to avoid the error of trying to access null as an array:

    session('message.status') === 'success'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search