Get original path and filename of hashed name in Laravel view - php

I have a Laravel application in production server that produces exception when rendering the view. The log file printed stacktraces about where the exception happened, but with hashed name of view.
How do I get the original path and the filename of hashed view? Since I can only debug from the error log in the server. For example with this stacktrace, I want to find the original file path and name of 698a6499f344ea0485830fd76f437b7ae1833431.php
ErrorException: Undefined property: stdClass::$balance_perdana in /var/app/current/storage/framework/views/698a6499f344ea0485830fd76f437b7ae1833431.php:44
Stack trace:
#0 /var/app/current/storage/framework/views/698a6499f344ea0485830fd76f437b7ae1833431.php(44): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined prope...', '/var/app/curren...', 44, Array)
#1 /var/app/current/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(42): include('/var/app/curren...')
There are solution that uses laravel debugbar (https://github.com/barryvdh/laravel-debugbar) to help find the related view, but I think this is not a good practice, activate debug mode in production environment.

Laravel stores compiled version file to speed up system execution.
Once your file is compiled and if you do not make changes into it then laravel direct executes this compiled version and this is how laravel executes fast process work.
So, displaying original name of file is not feasible.
Now for the solution, you can comment out your blade file name with <!-- BLADEFILENAME--> into particular file. So while facing any error then you can understand that which file is this.
Review Reference: Laravel blade debug view name on error

Related

How to find exact error line in laravel 5.4 blade?

I know laravel caches blade files, and when there is an error in blade, in version 5.3 error would be something like this :
Undefined offset: 0 (View:b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php) line: 47
Then I can go to cached files and find the exact line,
But in version 5.4 laravel reference the exact blade file(not cached file) but without a line number! Something like this :
Undefined offset: 0 (View: C:\wamp64\www\project\resources\views\events\partial\event_details_members.blade.php)
in Collection.php (line 1537)
Now how to find the error?
UPDATE
I know where the problem is, and how to fix that, But I want Laravel to tell me this automatically whether I have to look for it manually. what if the blade file is very big?
As of Laravel 5.7, the output shows stack frames on the left side and details of selected frame on right side. If you cruise through the stack, you'll find that one of the entries in there is the parsed version of your blade file (normally located near the (main) frame towards the bottom of the stack). Clicking this frame will take you to the exact line of the blade file that resulted in that exception.
its not an easy way to find the error which raised in a cached view file.
but if your debug mode is off and you are going to find it out very quick,
I suggest this following steps:
I know this is not tidy.
1- find error in ./storage/laravel/log/today.log :
for example:
(b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php) (line : 47)
2- output the files content usng cat :
cat ./storage/framework/view/b5c0ef4df49585eadd7fc1fa15b2d8a03e8c3bdd.php
(file name from error log)
3- copy the content from terminal to an editor (from first line to the end)
4- you can find the buggy line.
You can use Laravel Debugbar. This is easy to use. Follow below link you will get what you want.
https://github.com/barryvdh/laravel-debugbar

'Twig_Error_Syntax' with message 'Unknown "render" filter

I'm running drupal 8, composer and npm to perform gulp tasks.
When I run npm start.. my task manager: I get the following stack trace:
Fatal error: Uncaught exception 'Twig_Error_Syntax' with message 'Unknown "render" filter.' in /web/project/web/themes/emulsify/components/_patterns/04-templates/basic-page/_basic_page.twig:26
Stack trace:
#0 /web/project/web/themes/emulsify/pattern-lab/vendor/twig/twig/lib/Twig/ExpressionParser.php(481): Twig_ExpressionParser->getFilterNodeClass('render', 26)
#1 /web/project/web/themes/project_theme/pattern-lab/vendor/twig/twig/lib/Twig/ExpressionParser.php(466): Twig_ExpressionParser->parseFilterExpressionRaw(Object(Twig_Node_Expression_Name))
#2 /web/project/web/themes/project_theme/pattern-lab/vendor/twig/twig/lib/Twig/ExpressionParser.php(320): Twig_ExpressionParser->parseFilterExpression(Object(Twig_Node_Expression_Name))
#3 /web/project/web/themes/project_theme/pattern-lab/vendor/twig/twig/lib/Twig/ExpressionParser.php(212): Twig_ExpressionParser->parsePostfixExpression(Object(Twig_Node_Expression_Name))
#4 /web/project in /web/project/web/themes/project_theme/components/_patterns/04-templates/basic-page/_basic_page.twig on line 26
I've looked at installing twig-bridge / symfony twig via composer but I can't seem to get rid of the error message.
Do I just ditch using the twig filter "render"?
Update: 14/08/17
I've also ran into the same problem when trying to use the drupal_block function provided via Drupal 8's twig_tweak module.
The problem in the code above is that your Twig extension class is extending the internal Drupal Twig extension class. That breaks the Twig extensions added by Drupal core and that's why you are getting the error.
To fix this, you should make your Twig extensions extend Twigs internal Twig extension class. Your class should be defined like this:
class MyExtension extends \Twig_Extension {
After making that change, you can also remove arguments set for that class from the MODULE.services.yml
link
I've not seen this in the Drupal context, but working with other platforms that use Twig, I have seen similar issues occurring when an error occurs early in the platform setup process.
The typical sequence of events is like this:
The platform starts running its bootup; loading the CMS core, etc.
At some point early in this process, it hits an error.
It then tries to render an error page.
However, the error page uses a Twig template.
The startup process has not yet loaded all the twig extensions used in the template.
Boom, you get a twig error stating "unknown Twig function" instead of the real error message.
When I've had this before, it has proved very hard to diagnose what the actual error is.
The "correct" solution has been to modify the error page templates so that they are minimal and don't use any non-core twig functions. But if you're getting a crash early in the page load process it can be hard to actually do that.
In the first case, I resolved it by debugging the system and trapping what data was passed to the template. This showed me what the real error was. Resolving that error then stopped the twig error from occurring and allowed me to get into the system.
I don't know for sure if what you're seeing is the same kind of thing as what I was seeing, but it sounds similar so I hope this will help.

Drupal 8: You have requested a non-existent service "router.route_provider.old"

I am creating two custom content type with reference to these pages:
https://www.drupal.org/node/2629550
https://www.drupal.org/node/2693979
Uncaught PHP Exception
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException:
"You have requested a non-existent service
"router.route_provider.old". Did you mean one of these:
"router.route_provider", "router.route_preloader"?" at
...\core\lib\Drupal\Component\DependencyInjection\Container.php
line 157
Could anyone please help me, why this is happening and how to fix it ?
I am using Drupal 8.1.8 version.
I checked in core.services.yml file, there is no route declared as "router.route_provider.old"
I have created a router names as "router.route_provider.old" by copying "router.route_provider" in the core.services.yml file, which solves my problem.
i think Drupal uses "router.route_provider.old" router as a temporary to copy "router.route_provider" router info. But as this router name is not exists, its throwing exception.
I don't know if this is a bug or there is better way to fix it.
Update:
A patch is provided here: https://www.drupal.org/node/2788087

Array to string conversion - Project Crash [Laravel]

I am getting an error like this:
Array to string conversion
Inside:
/var/.../vendor/cartalyst/sentry/src/Cartalyst/Sentry/SentryServiceProvider.php
Code snippet where the error was thrown:
throw new \InvalidArgumentException("Invalid hasher [$hasher] chosen for Sentry.");
I was doing ordianry work in one of my controllers and this error occured when I clicked on one of the buttons inside my blade.
I have commented the code out but the error still is being displayed, not only on this one page but on every single one in my project. I can't even go to my /home/index.php page.
I have done
composer update
inside my project but that did not help. What can fix the problem?
#update
Yes I have checked sentry config file before I've made a new topic. I have the same problem when I load older versions (which do not contain the latest changes I've made today) of my project on to apache server which is running on Ubuntu 14.04.
Ideas what causes the problem?
In the config for Sentry you have to define a hasher.
It has to be a string. It can be 'native', 'bcrypt', 'sha256' or 'whirlpool'. Apparently in your app, it's not a string, but an array. Check your configuration. It's probably in app/config/packages/cartalyst/sentry/config.php

Fluidpage: Error when extending an extbase model

I was trying to extend tx_news with some extra fields and was getting an error so I installed this extension to see if that worked: https://github.com/cyberhouse/t3ext-newsauthor
I get the same error on the news pages with my extension and the reference extension:
Sorry, the requested view was not found.
The technical reason is: No template was found. View could not be
resolved for action "error" in class
"Tx_Fluidpages_Controller_PageController".
and the following errors in the be log:
Core: Error handler (FE): PHP Warning: file_get_contents(): Filename
cannot be empty in
/var/www/ukcg6/typo3_src-6.1.7/typo3/sysext/fluid/Classes/View/TemplateView.php
line 187
I am using Typo3 6.1 with:
Fluidpages 2.1.0
Fluidcontent 3.1.0
Flux 6.0.3
VHS 1.8.5
I don't have time to setup your stack here now, but I'll try to help with some general advice on how to trace and locate such kinds of errors.
Basically you will need to trace the error back from the TemplateView.php line 187.
Starting there you look for the variable which is the filename. You can var_dump() that variable and it will probably be "null".
Then you follow that variable back to its origin in backwards order. That means each time this variable gets passed you search for the place in the source code where the function which gets it as a parameter is called.
Doing this you'll definitely find the point where something goes wrong. The filename variable is not properly set and that means one of the previously called functions which should set it screwed up.

Categories