1

I'm working on a Laravel application and after some updates I keep getting a comma "," in every http response or console output so I'm crazy trying to find which script file is printing that character.

Is it possible to know which file is writing to the output http response or console?


UPDATE

I've put an echo call in Composer's ClassLoader vendor\composer\ClassLoader.php after an include function for the loaded classes is called, as follows:

/**
 * Scope isolated include.
 *
 * Prevents access to $this/self from included files.
 */
function includeFile($file)
{
    include $file; echo $file . "\n";
}

And now the comma appears between the following classes are loaded, is this helpful?

C:\Users\Bla\Bla\trunk\vendor/filp/whoops/src/Whoops/Handler/PrettyPageHandler.php 
,C:\Users\Bla\Bla\trunk\vendor/laravel/framework/src/Illuminate/Foundation/AliasLoader.php 
C:\Users\Bla\Bla\trunk\vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php

UPDATE 2

Found it! As @vladsch said, it was before an opening tag ,<?php in one of my config files, thanks

Joaquín L. Robles
  • 6,261
  • 10
  • 66
  • 96
  • yes, do die() on each part of code (better then use xdebug for this) and look in view – user1954544 Apr 05 '15 at 00:16
  • Maybe the die() function for this task in laravel is more hard than xdebug, xdebug automatically goes under all call functions and methods in all the chain of loaded files. With die you need manually to do that. – Edgar Orozco Apr 05 '15 at 01:32
  • Search your entire app for two commas (,,) you might find it. – afarazit Apr 05 '15 at 12:52

4 Answers4

1

Yes, you can, debugging with xdebug or other debbuger tool, step by step (step into) until you find the script.

See this stackover entry for guiadance.

I strongly recommend use a real debug tool as a good pro practice. But maybe for this particular purpouse its a little overwelming.

Community
  • 1
  • 1
Edgar Orozco
  • 2,722
  • 29
  • 33
1

You can probably narrow it down with some basic debugging. Add a dd('hello') throughout your application.

I would start in the routes.php file. See if the comma appears before or after the hello. If it is before the hello, then the comma is in one of the bootstrapping files.

If the comma is after the hello, then it is most likely in one of your views etc. Keep moving the dd('hello') deeper into your application until it appears.

Laurence
  • 58,936
  • 21
  • 171
  • 212
1

Since you have it in HTTP and console then this rules out the views.

The culprit is probably a comma inadvertently inserted before the opening <?php tag. Most likely one of the first ones that is at the top of every PHP file.

Do a search for ,<?php or for regex pattern /\s*,\s*<\?php/

vladsch
  • 606
  • 6
  • 7
  • 1
    To answer your direct question: potentially every script is writing output if it includes any text outside of the `` tags. A debugger won't help you in that case since php buffers its output. You won't see the output until the buffer is dumped unless you turn off buffering. – vladsch Apr 05 '15 at 12:29
0

No you cannot, that's why you should use a version control system (i.e.: git), so you can easily rollback whenever the system breaks.

In your case you could try to search for comma inside every single files of your working directory (escluding vendor and other unimportant folders such as storage)

If you have a debugger you could try to step into to check every single call from the beggining

dynamic
  • 46,985
  • 55
  • 154
  • 231