shpasser / GaeSupportL5

Google App Engine Support package for Laravel 5
MIT License
160 stars 27 forks source link

Unknown stream type php://stdout #2

Closed adamtester closed 9 years ago

adamtester commented 9 years ago

I seem to be getting this ErrorException, I believe its actually an error writing the error message, but I've used syslog as the command generated. Does anyone know what causes it?

ErrorException in AbstractDumper.php line 66:
fopen(php://stdout): failed to open stream: Unknown stream type php://stdout.

in AbstractDumper.php line 66
at HandleExceptions->handleError('2', 'fopen(php://stdout): failed to open stream: Unknown stream type php://stdout.', '/base/data/home/apps/s~app/1.382426911159954689/vendor/symfony/var-dumper/Symfony/Component/VarDumper/Dumper/AbstractDumper.php', '66', array('output' => 'php://stdout', 'prev' => null, 'this' => object(CliDumper)))
at fopen('php://stdout', 'wb') in AbstractDumper.php line 66
at AbstractDumper->setOutput('php://stdout') in AbstractDumper.php line 44
at AbstractDumper->__construct(null, null) in CliDumper.php line 52
at CliDumper->__construct() in DataFormatter.php line 21
at DataFormatter->__construct() in DataCollector.php line 43
at DataCollector::getDefaultDataFormatter() in DataCollector.php line 62
at DataCollector->getDataFormatter() in TimeDataCollector.php line 125
at TimeDataCollector->addMeasure('Booting', '1424686389.9316', '1424686392.182') in LaravelDebugBar.php line 124
at LaravelDebugbar->Barryvdh\Debugbar\{closure}(object(Application))
at call_user_func(object(Closure), object(Application)) in Application.php line 758
at Application->fireAppCallbacks(array(object(Closure))) in Application.php line 659
at Application->boot() in BootProviders.php line 15
at BootProviders->bootstrap(object(Application)) in Application.php line 167
at Application->bootstrapWith(array('Illuminate\Foundation\Bootstrap\DetectEnvironment', 'Illuminate\Foundation\Bootstrap\LoadConfiguration', 'Illuminate\Foundation\Bootstrap\ConfigureLogging', 'Illuminate\Foundation\Bootstrap\HandleExceptions', 'Illuminate\Foundation\Bootstrap\RegisterFacades', 'Illuminate\Foundation\Bootstrap\RegisterProviders', 'Illuminate\Foundation\Bootstrap\BootProviders')) in Kernel.php line 145
at Kernel->bootstrap() in Kernel.php line 106
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53
shpasser commented 9 years ago

I can see that you are using the Laravel Debugbar package. I will try to install it and investigate the issue myself.

Best,

Ron.

adamtester commented 9 years ago

Looking through the stack trace it seems to come from the debugbar, I will have a play when I finish work and see what I can find.

Adam

adamtester commented 9 years ago

Ok commenting out 'Barryvdh\Debugbar\ServiceProvider' in config/app.php solves the problem so it is an issue with that package, so I'll just have to do without, think I should open an issue over there?

Adam

shpasser commented 9 years ago

I am not sure that the issue is related to the Debugbar package, but to the lack of support of some PHP functionality it uses by GAE.

This is not the first one and I suppose not the last one.

The latest one was about fopen() function while using it on GCS buckets, it turns out that 'a' (append) mode is not supported on GCS buckets. The good news is that in most cases things work Ok.

I am going to try to reproduce the issue and find whatever is causing it. Then I might either add the missing feature to the GaeSupport package or submit a pull request to Debugbar.

Please keep me posted on your progress.

Thanks,

Ron.

shpasser commented 9 years ago

I did some digging and it turns out that it is possible to make it work without any pull requests. For now I suggest to use the following service provider I wrote for the task:

<?php namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use Symfony\Component\VarDumper\Dumper\HtmlDumper;
use Symfony\Component\VarDumper\Dumper\CliDumper;

/**
 * Class LineDumperServiceProvider
 *
 * Replaces the default output stream of Symfony's
 * CliDumper and HtmlDumper classes in order to
 * be able to run on Google App Engine.
 *
 * 'php://stdout' is used by CliDumper,
 * 'php://output' is used by HtmlDumper,
 * both are not supported on GAE.
 *
 * @package App\Providers
 */
class LineDumperServiceProvider extends ServiceProvider {

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        HtmlDumper::$defaultOutput =
        CliDumper::$defaultOutput =
            function($line, $depth, $indentPad)
            {
                if (-1 !== $depth)
                {
                    echo str_repeat($indentPad, $depth).$line."\n";
                }
            };
    }

    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

}

Please create 'LineDumperServiceProvider.php' in your 'app/Providers' folder and register the provider before anything else using Symfony's Dumpers, including 'Barryvdh\Debugbar\ServiceProvider', in your 'config/app.php':

'providers' => [
    'App\Providers\LineDumperServiceProvider',
];

Later on I'm planning on adding this provider to my GaeSupportL5 package.

Best,

Ron.

adamtester commented 9 years ago

Nice one! I'll give it a test on my gae app tonight.

Adam

adamtester commented 9 years ago

Ok I've been using your code last night and this morning and seems to have no issues! I'll let you know if I run into anything, thanks so much for this!

shpasser commented 9 years ago

The latest stable release 1.1 includes support for Symfony's dumpers.

vickgit commented 8 years ago

Hello, I was facing same issue in GAE. I changed php://stdout to php://temp and it worked.