profiler icon indicating copy to clipboard operation
profiler copied to clipboard

'Call to a member function getName() on a non-object'

Open erinnovations opened this issue 11 years ago • 3 comments

This partial view is fails in 4.1.19 with the error written in the title:

<table>
    <tr>
        <th>Key</th>
        <th>Value</th>
    </tr>
    <tr>
        <td>Current route</td>
<?php /* Check for Laravel Version */ ?>
<?php if (strpos($app::VERSION, '4.1') !== FALSE): ?>
        <td><?php echo Route::current()->getName(); ?></td>
<?php elseif (strpos($app::VERSION, '4.0') !== FALSE): ?>
        <td><?php echo Route::currentRouteName(); ?></td>
<?php endif; ?>
    </tr>
    <tr>
        <td>Current controller action</td>
<?php /* Check for Laravel Version */ ?>
<?php if (strpos($app::VERSION, '4.1') !== FALSE): ?>
        <td><?php echo Route::current()->getActionName(); ?></td>
<?php elseif (strpos($app::VERSION, '4.0') !== FALSE): ?>
        <td><?php echo Route::currentRouteAction(); ?></td>
<?php endif; ?>
    </tr>
</table>

This is my laravel.log:

[2014-02-01 20:24:32] dns_local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to a member function getName() on a non-object' in /Volumes/..../app/storage/views/1eaa4eae1b9904ef170ea7f598db4d38:10
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
#1 {main} [] []

erinnovations avatar Feb 01 '14 19:02 erinnovations

I forget to mention: I am using the latest 1.7.5 version of the profiler.

erinnovations avatar Feb 01 '14 19:02 erinnovations

Hi @erinnovations,

just a quick update: I started looking into this, but have a hard time replicating the issue. The 4.1.19 app I played with has roughly 40 routes and they come up fine. I noticed in the Laravel docs, that Route::currentRouteName(); seems to work under 4.1.x now as well?! I'll keep working on it!

Cheers, Seb

sebklaus avatar Feb 04 '14 07:02 sebklaus

Hey

I'm getting this error now when I redirect inside the app before. (Laravel 4.1.21)

Edit: seems like the Route::current is not been set. (dd(Route::current()) results in NULL)

MaatwebsiteSupport avatar Feb 14 '14 12:02 MaatwebsiteSupport