0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

log_xxx()/dump()

0
Posted at

はじめに

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

SymfonyProfiler→Logs→Info&Errors
Screenshot_2018-12-27 Symfony Profiler(1).png

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

SymfonyProfiler→Debug
Screenshot_2018-12-27 Symfony Profiler(2).png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?