Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php symfony2包括类pretty sql格式化程序和将sql输出到模板_Php_Symfony_Twig - Fatal编程技术网

Php symfony2包括类pretty sql格式化程序和将sql输出到模板

Php symfony2包括类pretty sql格式化程序和将sql输出到模板,php,symfony,twig,Php,Symfony,Twig,我希望使用作为symfony2库提供的漂亮的sql格式化程序。在模板页面上输出一些sql 这里包括格式化程序 /供应商/jdorn/sql格式化程序/lib/SqlFormatter 我会将其传递到细枝模板中 PageController.php $queryBaseSQL = "SELECT * FROM exampleTable WHERE 'this' = 1 "; return $this->render('sjQueryBundle:Page:index.html.twig',

我希望使用作为symfony2库提供的漂亮的sql格式化程序。在模板页面上输出一些sql

这里包括格式化程序 /供应商/jdorn/sql格式化程序/lib/SqlFormatter

我会将其传递到细枝模板中

PageController.php

$queryBaseSQL = "SELECT * FROM exampleTable WHERE 'this' = 1 ";

return $this->render('sjQueryBundle:Page:index.html.twig', array(
  'queryBaseSQL' => $queryBaseSQL
));
我希望能把它叫做“在树枝里面”,比如“在哪里”

(index.html.twig)

细枝:

细枝:


这很有效,谢谢-我会把它标记为正确答案。|raw是做什么的?为什么需要在SqlFormatter之前加前缀?如果使用SqlFormatter(不是\SqlFormatter),它会在命名空间中搜索SqlFormatter类(例如Acme\DemoBundle\Controller\SqlFormatter)|raw是指Twig不会在变量中转义HTML。这很有效,谢谢-我会将其标记为正确答案。|raw是做什么的?为什么需要在SqlFormatter之前加前缀?如果使用SqlFormatter(不是\SqlFormatter),它会在命名空间中搜索SqlFormatter类(例如Acme\DemoBundle\Controller\SqlFormatter)|raw是指细枝不会在变量中转义HTML。
{{ sqlFormatter::format(queryBaseSQL) }}
$queryBaseSQL = "SELECT * FROM exampleTable WHERE 'this' = 1 ";

return $this->render('sjQueryBundle:Page:index.html.twig', array(
  'queryBaseSQL' => \SqlFormatter::format($queryBaseSQL);
));
{{ queryBaseSQL|raw }}