M
M
Maxim Ivanushchik2015-11-05 18:53:44
Yii
Maxim Ivanushchik, 2015-11-05 18:53:44

Yii2 displays a white screen. Why?

For an hour now I can not understand why Yii2 Advanced displays pages only from the main controller (which is specified in the config as 'defaultRoute' => 'site'). All other pages do not open. Or rather, they open, but just a blank screen is displayed without any error messages.
I simplified the output as much as possible: I removed from the controllers the behavior to determine whether the user is authorized or not; removed the component responsible for authorization from the config; commented out in the same place all instructions unnecessary for the test.
Added to backend/web/index.php :

error_reporting(-1);
ini_set('display_errors', true);

In php.ini set:
error_reporting = E_ALL
display_errors = On
display_startup_errors = On

The server is running on a bunch of Apache 2 and Nginx.
Request:
GET /yii2/backend/web/index.php?r=test%2Findex HTTP/1.1
Host: *мой_хост*
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: ru,en-US;q=0.8,en;q=0.6
Cookie: __utma=222857945.2129854740.1435519076.1435519076.1435519076.1; __utmc=222857945; __utmz=222857945.1435519076.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _csrf=1d0e0163f286b1f1fb234401912aafe896bf696683f3199f7e5719a51796907ba%3A2%3A%7Bi%3A0%3Bs%3A5%3A%22_csrf%22%3Bi%3A1%3Bs%3A32%3A%226FsOE_vxJy0QFmU7tkp5OyVHpkbny6cw%22%3B%7D; _identity=94b058838e402ac88ced81c18744afa51af5d1ab75e6f8b4e4e714b420bec60da%3A2%3A%7Bi%3A0%3Bs%3A9%3A%22_identity%22%3Bi%3A1%3Bs%3A14%3A%22%5B1%2C%22%22%2C2592000%5D%22%3B%7D; PHPSESSID=kc7qvnb2no2edlfc3kcnadh5o5

Answer:
HTTP/1.1 200 OK
Server: nginx/1.6.2 (Ubuntu)
Date: Thu, 05 Nov 2015 15:30:06 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 0
Connection: keep-alive
Vary: Host
X-Powered-By: PHP/5.6.4-4ubuntu6.4

As a result, there are no corresponding errors either in the Apache error.log or in the yii app.log. The runtime directory is, of course, writable.
Just in case, I give the code of the controller and views.
Controller:
<?php
namespace backend\controllers;

use Yii;
use yii\web\Controller;

/**
 * Created by PhpStorm.
 * User: max
 * Date: 05.11.15
 * Time: 16:21
 */
class TestController extends Controller {
  /**
   * Renders the index page.
   * @return string rendered code
   */
  public function actionIndex() {
    $this->layout = 'test';
    $this->render('//index/test');
  }
}

Layout test.php:
<html>
<body>
<?= $content; ?>
</body>
</html>

Again, pages from the main SiteController are displayed normally.
Interestingly, if a non-existent view is set in $this->render , an error will be displayed. Those. the code before the render method is executed is still being worked out. Also, if errors are intentionally made in the view itself, it will be printed again. It turns out that the render method itself is processed.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Khomenko, 2015-11-05
@makis

return $this->render('//index/test');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question