1479

Laravel error with 404 page

Question:

im trying to implement code of 404 page in my website. Im using this code in my filters.php but i also tried to use in global.php

App::missing(function($exception) { return View::make('404'); }

as a result im getting this error:

Symfony \ Component \ Debug \ Exception \ FatalErrorException Call to a member function getAction() on a non-object

Answer1:

i do it an aother way. What is going to happen when 404 is raised is normally declared in app/start/global.php

It should looks like that :

App::error(function($exception, $code) { switch ($code) { case 403: return Response::view('errors.403', array(), 403); case 404: return Response::view('errors.404', array(), 404); } }

This just called the app/views/errors/404.blade.php anytime laravel raised a 404 or if you decide to manually call App::abort(404);

Hope it helps.

Answer2:

I googled more about this and how i understand it problem comes from nginx. could be? btw it is working without blade templating but i need it. so need to find out how to fix it

Answer3:

That look like in the views or composer of the layout or your 404 page. you have something like:

Route::getCurrentRoute()->getAction()

or

Route::current()->getAction()

Or as far I remember Route::getCurrentRoute when 404 would be null and then it explains your error...

I use to check if the current Route is instance of Route by:

$currentRoute = \Route::getCurrentRoute(); if ($currentRoute instanceof Route) { // Do What you want here $currentRoute->getAction()//... }

Recommend

  • Incorrect path using encoded polyline from Google Directions API in Static Maps
  • How to Convert Rtp Multicast Stream from DVB-T to HLS?
  • jquery selector question: do something only if all elements are hidden
  • Java: What is the best way to find elements in a sorted List?
  • `font-weight` Is not working on chrome?
  • Soundcloud JAVA api wrapper : SSLException
  • How to check if child component resource exist or not using Sightly in AEM?
  • Show alternate categorical labels in axis in ggplot2
  • REGEXP_REPLACE pattern has to be const? Comparing strings in BigQuery
  • how to change button text after succes in ajax
  • Angular not getting response when it's a non-200
  • Retrieve 3rd MAX salary in Hive
  • Salesforce API: How to identify a Case from an email reference code (“[Ref: … :Ref]”)?
  • no endpoints available for service \\“kubernetes-dashboard\\”
  • Is there a way to run c# forms application without showing a gui window (like a console application)
  • Greedy Algorithm in “C”
  • Extract table from Powerpoint
  • How to display youtube video on HTML page? [closed]
  • Unity Resources.load() won't work with external dll
  • How to display converted time zones in a 'generic week' (Sunday thru Saturday)?
  • Windows biometric framework sample umdf driver: This device cannot start. (Code 10)
  • Keep rows with certain values always at the bottom while sorting in jquery tablesorter plugin
  • Multiplying polynomials/simplifying like terms
  • How to define something in JavaScript [closed]
  • Comparing variables with strings bash
  • Support of :after in IE7
  • Amazon Elastick BeanStalk error: Failed to create the AWS Elastic Beanstalk application version
  • How to change user identity when git pushing via ssh?
  • Why isn't stemDocument stemming?
  • How to decleare char *const argv[] in swift [duplicate]
  • How to handle div that is created dynamically in a table
  • How to get rgb from transparent pixel in js
  • Grails - How to implement a foreign key relationship not using an id column?
  • Write to .csv file with PHP (Commas in Data Error)