Nette sandbox problem with debug mode

Notice: This thread is very old.
TrogWar
Member | 5
+
-1
-

Hello!

What i've done:

  1. installed nette/sandbox via composer into /var/www/nette
  2. cd /var/www/nette && chmod -R a+rw temp log
  3. make DocumentRoot as /var/www/nette/www && servce httpd restart. Welcome page is correctly opens via http://nette.example.com/
  4. Uncomment line with setDebugMode and have an error.

My app/bootstrap.php:

<?php

require __DIR__ . '/../vendor/autoload.php';

$configurator = new Nette\Configurator;
$configurator->setDebugMode(true); // debug mode MUST NOT be enabled on production server
$configurator->enableDebugger(__DIR__ . '/../log');
$configurator->setTempDirectory(__DIR__ . '/../temp');
$configurator->createRobotLoader()
    ->addDirectory(__DIR__)
    ->addDirectory(__DIR__ . '/../vendor/others')
    ->register();
$configurator->addConfig(__DIR__ . '/config/config.neon');
$configurator->addConfig(__DIR__ . '/config/config.local.neon');
$container = $configurator->createContainer();

return $container;

And error is here (link to screenshot)

What i'm doing it wrong? How can i fix it?

Thank you.

Last edited by TrogWar (2014-06-01 17:45)

Tomáš Votruba
Moderator | 1114
+
0
-

Hi, this usually means there is already echoed some code before application starts.

  • Look for dump(), echo and similar.
  • Or try line by line die; in bootstrap to find out where exactly this happens.
  • Also try look in the page's source. There might be text causing the error at the very beginning.
  • Sometimes cleaning the cache helps.

Last edited by Tomáš Votruba (2014-06-01 21:06)

TrogWar
Member | 5
+
0
-

I've just install framework and haven't added a single line of code to this sandbox app.
Error occurs only if i set debug mode to true here (GitHub link). With false debug app renders without errors.

Last edited by TrogWar (2014-06-01 21:36)

Šaman
Member | 2634
+
0
-

It's working to me. What editor (or server) you use?

TrogWar
Member | 5
+
0
-

Some info

Tested on two machines:

  • macos 10.9.3 + apache 2.2 + php 5.4.4
  • centos 6.5 + apache 2.2 + php 5.6.0

I've installed app via PHPStorm –> New project –> Type: “Composer project” –> Package: “nette/sandbox”.

Much more info

[trogwar@centos ~]$ rpm -qa \*-release\*
centos-release-6-5.el6.centos.11.2.i686
[trogwar@centos ~]$ httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Apr  3 2014 23:53:54
[trogwar@centos ~]$ php -v
PHP 5.6.0beta1 (cli) (built: Apr 10 2014 10:33:21)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0-dev, Copyright (c) 1998-2014 Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
[trogwar@centos ~]$ ls -al /var/www/nette/
итого 1036
drwxrwxrwt.  9 trogwar trogwar   4096 Июн  2 00:03 .
drwxr-xr-x. 12 root    root      4096 Июн  1 23:18 ..
drwxrwxrwt.  7 trogwar trogwar   4096 Июн  1 23:21 app
drwxrwxrwt.  2 trogwar trogwar   4096 Июн  1 23:21 bin
-rwxrwxrwt.  1 trogwar trogwar    609 Май 28 18:05 composer.json
-rwxrwxrwt.  1 trogwar trogwar  39903 Июн  1 23:15 composer.lock
-rwxrwxrwt.  1 trogwar trogwar 962949 Июн  1 23:15 composer.phar
-rwxrwxrwt.  1 trogwar trogwar      0 Июн  1 23:18 error.log
-rwxrwxrwt.  1 trogwar trogwar    112 Май 28 18:05 .gitignore
-rwxrwxrwt.  1 trogwar trogwar   1985 Май 28 18:05 license.md
drwxrwxrwt.  2 trogwar trogwar   4096 Июн  1 23:50 log
-rwxrwxrwt.  1 trogwar trogwar   1438 Май 28 18:05 readme.md
drwxrwxrwt.  4 trogwar trogwar   4096 Июн  1 23:22 temp
drwxrwxrwt.  2 trogwar trogwar   4096 Июн  1 23:21 tests
drwxrwxrwt.  9 trogwar trogwar   4096 Июн  1 23:21 vendor
drwxrwxrwt.  6 trogwar trogwar   4096 Июн  1 23:21 www
[trogwar@centos ~]$ tree -L 2 /var/www/nette/
/var/www/nette/
├── app
│   ├── bootstrap.php
│   ├── config
│   ├── model
│   ├── presenters
│   ├── router
│   ├── templates
│   └── web.config
├── bin
│   └── create-user.php
├── composer.json
├── composer.lock
├── composer.phar
├── error.log
├── license.md
├── log
│   ├── access.log
│   ├── error.log
│   └── web.config
├── readme.md
├── temp
│   ├── cache
│   ├── sessions
│   └── web.config
├── tests
│   ├── bootstrap.php
│   └── ExampleTest.phpt
├── vendor
│   ├── autoload.php
│   ├── bin
│   ├── composer
│   ├── dg
│   ├── latte
│   ├── nette
│   ├── others
│   ├── tracy
│   └── web.config
└── www
    ├── adminer
    ├── css
    ├── favicon.ico
    ├── images
    ├── index.php
    ├── js
    ├── robots.txt
    └── web.config

25 directories, 21 files
Milo
Nette Core | 1283
+
0
-

@TrogWar: The screenshot you sent says that an output starts here. It is a little bit strange.

Can you find some logs in log directory (when run in non-debug mode)?

It would be usefull to catch the outputted content. You can put Tracy\OutputDebugger::enable() to very begin of bootstrap.php. Than refresh the page and checkout the HTML output in browser.

Milo
Nette Core | 1283
+
0
-

@TrogWar And the simplest way… when you get a red screen (Tracy), pres Escape and take a look at output. :)

TrogWar
Member | 5
+
0
-

Can you find some logs in log directory (when run in non-debug mode)?

If open page with debug off, in log

[trogwar@centos log]$ cat error.log
[2014-06-02 06-32-58] PHP Warning: stream_wrapper_unregister(): Unable to unregister protocol safe:// in /var/www/nette/vendor/nette/safe-stream/src/SafeStream/SafeStream.php:57  @  http://nette.centos/
[2014-06-02 06-32-58] PHP Warning: fopen(/var/www/nette/temp/cache/_Nette.Database.799f712f502b84b8d8ce2d96b3ef3d99/_07414f4e15ca943e6cde032dec85d92f): failed to open stream: No such file or directory in /var/www/nette/vendor/nette/caching/src/Caching/Storages/FileStorage.php:320  @  http://nette.centos/

First error occurs because i have scream-mode enabled in php (Nette uses @-operator here). If i disable scream-mode, no errors (even second, there is really no such file in cache dir) added in log at all but subj problem not solved.

It would be usefull to catch the outputted content. You can put Tracy\OutputDebugger::enable() to very begin of bootstrap.php. Than refresh the page and checkout the HTML output in browser.

Thanks for the tip. Put it right after requiring autoloader and see same exception as on screenshot. If debug mode not enabled – normal output.

And the simplest way… when you get a red screen (Tracy), pres Escape and take a look at output. :)

Cool feature (: Found tons of debug backtrace lines, but first error says:

Nette\Utils\AssertionException: Missing section 'production' in file '/var/www/html/nette/app/config/config.neon'. in /var/www/html/nette/vendor/nette/utils/src/Utils/Validators.php on line 104

Reading the docs about configuration does not answer to question what excaclty config Nette needs to work properly in my config.neon file? Any example?

Full stacktrace doesn't fit into comment. If needed, you can view it here.

Last edited by TrogWar (2014-06-02 08:44)

Milo
Nette Core | 1283
+
0
-

This is strange. Which version exactly did you install by PhpStorm? I installed most of the last and no problem. Try last stable v2.2.1.

The production and development sections used to be use in v2.0.x. But now, multiple NEON configuration files are supported and sections are not necessarry. The error seems to me as some strange composer lib versions mixing.

Btw, do you use some own error/exception handler?

TrogWar
Member | 5
+
0
-

Btw, do you use some own error/exception handler?

In code, i don't have any custom handler for errors.
But i found that in php.ini was enabled xdebug.show_exception_trace. Tracy and xdebug conflict with each other: xdebug tried to output error but after this tracy (or nette?) send session headers.

Disabling “xdebug.show_exception_trace” solved this problem. How easy (:

Thank you, Milo, for your patience and help!