log_xxx()/dump()
はじめに
EC-CUBEというかSymfony3アプリケーションのデバックでデータのダンプなど
log_xxx()
log_error()/log_info()など
app/Customize/Controller/SamplePageController.php
/**
* @Route("/sample/{id}", name="sample_index")
* @Template("Sample/index.twig")
*/
public function index($id)
{
$product = $this->productRepository->find($id);
$size_a = $product->getProductSize()->getSizeA();
$size_b = $product->getProductSize()->getSizeB();
log_info(sprintf("%s(%d)", __FILE__, __LINE__), [$size_a, $size_b]); // Arrayだけ
$product->getProductSize()->setSizeA($size_a + 1);
$this->entityManager->persist($product);
$this->entityManager->flush();
return [
'shop_name' => $this->baseInfo->getShopName(),
'product_name' => $product->getName(),
'maker_name' => $product->getMakerName(),
'size_a' => $product->getProductSize()->getSizeA(),
];
}
Symfony Profiler
app/Customize/Controller/SamplePageController.php
/**
* @Route("/sample/{id}", name="sample_index")
* @Template("Sample/index.twig")
*/
public function index($id)
{
$product = $this->productRepository->find($id);
$size_a = $product->getProductSize()->getSizeA();
$size_b = $product->getProductSize()->getSizeB();
log_info(sprintf("%s(%d)", __FILE__, __LINE__), [$size_a, $size_b]); // Arrayだけ
$product->getProductSize()->setSizeA($size_a + 1);
$this->entityManager->persist($product);
$this->entityManager->flush();
return [
'shop_name' => $this->baseInfo->getShopName(),
'product_name' => $product->getName(),
'maker_name' => $product->getMakerName(),
'size_a' => $product->getProductSize()->getSizeA(),
];
}
SymfonyProfiler→Logs→Info&Errors
dump()
app/Customize/Controller/SamplePageController.php
/**
* @Route("/sample/{id}", name="sample_index")
* @Template("Sample/index.twig")
*/
public function index($id)
{
$product = $this->productRepository->find($id);
$size_a = $product->getProductSize()->getSizeA();
$size_b = $product->getProductSize()->getSizeB();
dump($product); // Objectでも良い
dump([$size_a, $size_b]); // Arrayでも良い
$product->getProductSize()->setSizeA($size_a + 1);
$this->entityManager->persist($product);
$this->entityManager->flush();
return [
'shop_name' => $this->baseInfo->getShopName(),
'product_name' => $product->getName(),
'maker_name' => $product->getMakerName(),
'size_a' => $product->getProductSize()->getSizeA(),
];
}
Symfony Profiler
app/Customize/Controller/SamplePageController.php
/**
* @Route("/sample/{id}", name="sample_index")
* @Template("Sample/index.twig")
*/
public function index($id)
{
$product = $this->productRepository->find($id);
$size_a = $product->getProductSize()->getSizeA();
$size_b = $product->getProductSize()->getSizeB();
dump($product); // Objectでも良い
dump([$size_a, $size_b]); // Arrayでも良い
$product->getProductSize()->setSizeA($size_a + 1);
$this->entityManager->persist($product);
$this->entityManager->flush();
return [
'shop_name' => $this->baseInfo->getShopName(),
'product_name' => $product->getName(),
'maker_name' => $product->getMakerName(),
'size_a' => $product->getProductSize()->getSizeA(),
];
}
Author And Source
この問題について(log_xxx()/dump()), 我々は、より多くの情報をここで見つけました https://qiita.com/ma33588/items/11e494cd4b74746250ee著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .