Framework: Artisan commands will not show line numbers of errors on php7+

Created on 27 Mar 2017  路  10Comments  路  Source: laravel/framework

  • Laravel Version: 5.4.16 (and previous)
  • PHP Version: 7+, 7.1+

Description:

When running an artisan command on Windows that contains an error the error message is shown without a line-number on php 7+.

On php 5.6 the error is shown with the line number.

This does not happen on all files, for instance adding an error to the actual artisan file will show the line number but adding an error to MigrateCommand.php will not.

Steps To Reproduce:

  • Windows with php 7+
  • Create a fresh install of Laravel.
  • Add an error to \artisan and run php artisan - the line number will be shown with the error
  • Remove above error and add one to \vendor\laravel\framework\src\Illuminate\Database\Console\Migrations\MigrateCommand.php - the error will be shown without the line number

PHP 5.6
php56

PHP 7
php7

Most helpful comment

This is still a serious issue, and -v or --verbose has no effect in my Install. Why is this closed?

All 10 comments

@SirriC can you try running PHP script that throws an error? do you see line numbers?

@Dylan-DPC Yes, if I have a simple php file with an error it鈥檒l show the line number.

I also get line numbers up to a point in Laravel, so I can edit some files and see them but then they stop showing. I think it might be when the errors are handled by Symfony - see the bottom screenshot in my original post. The first time I run artisan it files the error on line 16. On the second run the error is much deeper into the application and no line number is shown.

It turns out this is not just on Windows. My colleague was actually running php 5.6. I have also tried php 7.1 on two linux machines and neither show line numbers for errors.

image

Try running with the -v option

Use --verbose to get more information about the error if you want.

This is still a serious issue, and -v or --verbose has no effect in my Install. Why is this closed?

Agreed, having same issue here....

I'm having the same issue. Using Windows 10, PHP 5.6, Laravel 5.4. --verbose flag doesn't work:

error

For those experiencing a similar issue, I found that's it's more verbosely logging the error in storage/logs/laravel.log

Seems to be an issue with the php.ini being shipped with PHP >= 7.0 (possibly earlier too if a newer version of Xdebug is used). Since Xdebug 2.4 there's a new option available xdebug.show_error_trace, this should be set to 1 in your xdebug-configuration (or just your php.ini), note that this should be the php.ini for CLI, not FPM.

I.e, if using Homestead just put:

xdebug.show_error_trace=1 somewhere in /etc/php/7.1/cli/php.ini and it should work.

Discussion on Twitter about this: https://twitter.com/mattiasgeniar/status/905450118152953857

This is not related to xdebug and is still an issue for 2 years now?

Was this page helpful?
0 / 5 - 0 ratings