# Pimcore(Symfony+Twig)開発ティップス

**URL:** https://forum.ficusonline.com/t/topic/428
**Category:** WEB Design
**Created:** [2021 年 8 月 9 日午前 9:11 UTC](https://forum.ficusonline.com/t/topic/428 "2021-08-09T09:11:32Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 8 月 9 日午前 9:11 UTC](https://forum.ficusonline.com/t/topic/428/1 "2021-08-09T09:11:32Z")

</div>

### Pimcoreアップグレートに伴うブラッシュアップ

**Link Generator**  
[https://pimcore.com/docs/pimcore/current/Development\_Documentation/Objects/Object\_Classes/Class\_Settings/Link\_Generator.html#page\_Link-Generator](https://pimcore.com/docs/pimcore/current/Development_Documentation/Objects/Object_Classes/Class_Settings/Link_Generator.html#page_Link-Generator)

**Pimcore Twig Extensions(Template Extensions)**  
[https://pimcore.com/docs/pimcore/current/Development\_Documentation/MVC/Template/Template\_Extensions/index.html#page\_Pimcore-Twig-Extensions](https://pimcore.com/docs/pimcore/current/Development_Documentation/MVC/Template/Template_Extensions/index.html#page_Pimcore-Twig-Extensions)

**Symfony(PHP Framework)**

> **[GitHub - symfony/symfony: The Symfony PHP framework](https://github.com/symfony/symfony)**
>
> The Symfony PHP framework

**Twig(PHP Template Engine)**

> **[Documentation - Twig - The flexible, fast, and secure PHP template engine](https://twig.symfony.com/doc/3.x/)**
>
> Twig - The flexible, fast, and secure template engine for PHP

**Pimcore Forum**

> **[pimcore pimcore · Discussions](https://github.com/pimcore/pimcore/discussions)**
>
> Explore the GitHub Discussions forum for pimcore pimcore. Discuss code, ask questions & collaborate with the developer community.

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 8 月 15 日午後 2:29 UTC](https://forum.ficusonline.com/t/topic/428/2 "2021-08-15T14:29:56Z")

</div>

> **[Multiple detail page · pimcore · Discussion #10024](https://github.com/orgs/pimcore/discussions/10024)**
>
> Hello, Facing issue with multiple detail page. In application there are two module one is blog and other one is news. I want to show detail pages of both blog and news. I followed pimcore demo codi...

**Newsオブジェクト** を参照して **Blogオブジェクト** を作成後、Newsリストのページから詳細ページへのロードエラー発生（NewsコントローラではなくBlogコントローラを読み込んでしまう）

以下 **`BlogController.php`** 内のリンク先URLのフォーマットを見直し。

**BlogController.php**  
`~b{blog}`

```auto
@Route("{path}/{blogtitle}~b{blog}", name="blog-detail", defaults={"path"=""}, requirements={"path"=".*?", "blogtitle"="[\w-]+", "blog"="\d+"})

```

**NewsController.php**  
`~n{news}`

```auto
@Route("{path}/{newstitle}~n{news}", name="news-detail", defaults={"path"=""}, requirements={"path"=".*?", "newstitle"="[\w-]+", "news"="\d+"})

```

### Using Param Converter to convert request ID to Data Object

[https://pimcore.com/docs/pimcore/current/Development\_Documentation/MVC/Routing\_and\_URLs/Custom\_Routes.html#page\_Using-Param-Converter-to-convert-request-ID-to-Data-Object](https://pimcore.com/docs/pimcore/current/Development_Documentation/MVC/Routing_and_URLs/Custom_Routes.html#page_Using-Param-Converter-to-convert-request-ID-to-Data-Object)

### Symfony @ParamConverter

**Pimcore** は **Symfony** フレームワークにより構築されているため、 **Route** に関しては以下の **Routing** , **@ParamConverter** も参照のこと

**Routing**

> **[Routing (Symfony Docs)](https://symfony.com/doc/current/routing.html)**
>
> When your application receives a request, it calls a controller action to generate the response. The routing configuration defines which action to run for each incoming URL. It also provides other use…

**@ParamConverter**

> **[@ParamConverter (SensioFrameworkExtraBundle Documentation)](https://symfony.com/bundles/SensioFrameworkExtraBundle/current/annotations/converters.html)**
>
> Usage The @ParamConverter annotation calls converters to convert request parameters to objects. These objects are stored as request attributes and so they can be injected as controller method argument…

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 8 月 17 日午前 7:05 UTC](https://forum.ficusonline.com/t/topic/428/3 "2021-08-17T07:05:26Z")

</div>

## Symfony5

### Twigテンプレートからコントローラ（ファンクション）の呼出し

> **[Embedding Controllers - Creating and Using Templates (Symfony Docs)](https://symfony.com/doc/current/templates.html#embedding-controllers)**
>
> A template is the best way to organize and render HTML from inside your application, whether you need to render HTML from a controller or generate the contents of an email. Templates in Symfony are created with Twig: a flexible, fast, and secure...

**EX)**

**コントローラ**

```auto
// src/Controller/BlogController.php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
// ...

class BlogController extends AbstractController
{
    public function recentArticles(int $max = 3): Response
    {
        // get the recent articles somehow (e.g. making a database query)
        $articles = ['...', '...', '...'];

        return $this->render('blog/_recent_articles.html.twig', [
            'articles' => $articles
        ]);
    }
}

```

**上記コントローラの `recentArticles` で指定したTwigテンプレート**

```auto
{# templates/blog/_recent_articles.html.twig #}
{% for article in articles %}
    <a href="{{ path('blog_show', {slug: article.slug}) }}">
        {{ article.title }}
    </a>
{% endfor %}

```

**他のTwigテンプレートから上記コントローラの呼出し**  
`{{ render(controller( 'App\\Controller\\BlogController::recentArticles', {max: 3} )) }}`

```auto
{# templates/base.html.twig #}

{# ... #}
<div id="sidebar">
    {# if the controller is associated with a route, use the path() or url() functions #}
    {{ render(path('latest_articles', {max: 3})) }}
    {{ render(url('latest_articles', {max: 3})) }}

    {# if you don't want to expose the controller with a public URL,
       use the controller() function to define the controller to execute #}
    {{ render(controller(
        'App\\Controller\\BlogController::recentArticles', {max: 3}
    )) }}
</div>

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 8 月 17 日午前 11:45 UTC](https://forum.ficusonline.com/t/topic/428/4 "2021-08-17T11:45:39Z")

</div>

### Pimcore Select

[https://pimcore.com/docs/pimcore/current/Development\_Documentation/Documents/Editables/Select.html](https://pimcore.com/docs/pimcore/current/Development_Documentation/Documents/Editables/Select.html)

**ブログとニュースのリストアップスニペットをPHPからTwigテンプレートへ変更**

**`templates/snippets/footer-sammary.html.twig`**

```auto
{% if editmode %}
    <style type="text/css">
        .teaser {
            max-width: 250px;
        }

        .teaser img {
            max-width: 100%;
        }
    </style>

    <h3>How many News titles should be listed? (default:1):</h3>
    {{ pimcore_select('newsTitles', {
        width: 70,
        reload: true,
        store: [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],
        class: 'align-middle'
    }) }}

    <br />
    <hr />

    <h3>How many Blog titles should be listed? (default:1):</h3>
    {{ pimcore_select('blogTitles', {
        width: 70,
        reload: true,
        store: [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],
        class: 'align-middle'
    }) }}

{% else %}
    <div class="panel-heading pb-4">
        <h4 class="card-title text-light">{{ 'Information'|trans }}</h4>
    </div>

    {% set count = pimcore_select('newsTitles').getData() %}
    {% if count is empty or count == 0 %}
        {% set count = 1 %}
    {% endif %}
    {{ render(controller(
        'App\\Controller\\NewsController::titleListAction', { 'items': '(int) $count' }
    )) }}

    {% set count = pimcore_select('blogTitles').getData() %}
    {% if count is empty or count == 0 %}
        {% set count = 1 %}
    {% endif %}
    {{ render(controller(
        'App\\Controller\\BlogController::titleListAction', { 'items': '(int) $count' }
    )) }}

{% endif %}

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 8 月 18 日午後 2:33 UTC](https://forum.ficusonline.com/t/topic/428/5 "2021-08-18T14:33:53Z")

</div>

### Snippet内でのLink Generator

SidebarやFooter内でNewsやBlog記事をリストアップするSnippetを作成した際、以下のSnippetメソッドエラー発生。

> An exception has been thrown during the rendering of a template (“Call to undefined method getTitle in class Pimcore\Model\Document\Snippet”).

Link GeneratorでSnippetのディレクトリ `shared/teasers` を読み込まないよう以下修正。  
（ **editmode** 時は除外、 **document** 時のみ適用）

**`Website/LinkGenerator/NewsLinkGenerator.php`**

```auto
.....
.....
/* if($document && !$fullPath) { */
if($document) {
$fullPath = $document->getProperty('news_default_document') ? substr($document->getProperty('news_default_document')->getFullPath(), strlen($localeUrlPart)) : '';
} 
.....
.....

```

**`Website/LinkGenerator/BlogLinkGenerator.php`**

```auto
.....
.....
/* if($document && !$fullPath) { */
if($document) {
$fullPath = $document->getProperty('blog_default_document') ? substr($document->getProperty('blog_default_document')->getFullPath(), strlen($localeUrlPart)) : '';
}
.....
.....

```

**`news_default_document, blog_default_document`** は以下の **`Predefined Proparties`** で定義後、任意の **Document** の **`Navigation&Properties`** で **NewsとBlogリストページのパス** を指定すること。

**`Predefined Proparties`**

 ![predefined_proparties](https://forum.ficusonline.com/uploads/default/original/1X/27e9084885fb24bae7223753788a65324c6b1d9f.png)

**`Navigation&Properties`**

 ![home_navigation_properties](https://forum.ficusonline.com/uploads/default/original/1X/f06e13c66099cef5ae3702ac8707db3cc95172c0.png)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 8 月 19 日午前 6:51 UTC](https://forum.ficusonline.com/t/topic/428/6 "2021-08-19T06:51:52Z")

</div>

### Twig文字制限

> <https://stackoverflow.com/questions/13143001/symfony-2-twig-limit-the-length-of-the-text-and-put-three-dots>

**Twig length**

> **[length - Filters - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/filters/length.html)**
>
> Twig - The flexible, fast, and secure template engine for PHP

**Twig slice**

> **[slice - Filters - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/filters/slice.html)**
>
> Twig - The flexible, fast, and secure template engine for PHP

```auto
{{ myentity.text[:50] ~ (myentity.text|length > 50 ? '…') }}

```

**補足：省略記号 ellipsis character ‘…’**  
スリードット `...` ではなく1つのキャラクターとして `…` を表示

**注）Linux:Ubuntuの場合（MAC,Windowsではキーが異なります）**

1. Ctrl + Shift + ‘u’ 押下
2. キーリリース
3. 続けて"2026"を入力,
4. エンターキー押下

**Twig dump**

テンプレート内の変数確認

> **[dump - Functions - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/functions/dump.html)**
>
> Twig - The flexible, fast, and secure template engine for PHP

```auto
<pre>
    {{ dump(item) }}
</pre>

```

```auto
Pimcore\Model\DataObject\Fieldcollection\Data\NewsText {#2378 ▼
  #type: "NewsText"
  #localizedfields: Pimcore\Model\DataObject\Localizedfield {#2384 ▶}
  #index: 0
  #fieldname: "content"
  #object: null
  #objectId: 1158
  #dao: null
  #_fulldump: false
  #loadedLazyKeys: []
  #o_dirtyFields: null
  type: "NewsText"
  localizedfields: Pimcore\Model\DataObject\Localizedfield {#2384 ▶}
  index: 0
  fieldname: "content"
  object: null
  objectId: 1158
  _fulldump: false
  loadedLazyKeys: []
  o_dirtyFields: null
}

```

**Twig striptags**

htmlテキストファイルから `<p>,<br>` 等のタグを除外

> **[striptags - Filters - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/filters/striptags.html)**
>
> Twig - The flexible, fast, and secure template engine for PHP

EX) テキストソース頭から200文字を抽出後タグを削除。文字数が200文字を超えていたら `'…' ` による省略記号追加。

```auto
{% if news.content %}
    {% for item in news.content.items %}
        {% if item.type == "NewsText" %}
            {{ item.text[:200] | striptags ~ (item.text|length > 200 ? '…') }}
        {% endif %}   
    {% endfor %}
{% endif %}

```

'~'によるフィルタリングを施すと特殊文字（例：`&#039;`）がそのまま出力されてしまうため以下の記述に変更。

```auto
{% if news.content %}
    {% for item in news.content.items %}
        {% if item.type == "NewsText" %}
            {{ item.text[:200] | striptags | raw }} .....
        {% endif %}   
    {% endfor %}
{% endif %}

```

**Twig Replace**

> **[replace - Filters - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/filters/replace.html)**
>
> Twig - The flexible, fast, and secure template engine for PHP

上記のタグ削除に **non-breaking space** `&nbsp;` の`" "`への置換え追加  
non-breaking spaceは、単位と数値の間の改行禁止のスペース

- § 10
- 10 km/h
- 10 PM

```auto
{% if news.content %}
    {% for item in news.content.items %}
        {% if item.type == "NewsText" %}
            {{ item.text[:200] | striptags | replace({'&nbsp;': " "}) ~ (item.text|length > 200 ? '…') }}
        {% endif %}   
    {% endfor %}
{% endif %}

```

**Twig Operators**

> **[Other Operators - Twig for Template Designers - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/templates.html#other-operators)**
>
> The following operators don't fit into any of the other categories: | Twig - The flexible, fast, and secure template engine for PHP

**条件設定**

- `?:`: The ternary operator:

```auto
{{ foo ? 'yes' : 'no' }}
{{ foo ?: 'no' }} is the same as {{ foo ? foo : 'no' }}
{{ foo ? 'yes' }} is the same as {{ foo ? 'yes' : '' }}

```

**Twig Logic**

**論理条件定義**

> **[Logic - Twig for Template Designers - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/templates.html#logic)**
>
> You can combine multiple expressions with the following operators: | Twig - The flexible, fast, and secure template engine for PHP

- `and`: Returns true if the left and the right operands are both true.
- `or`: Returns true if the left or the right operand is true.
- `not`: Negates a statement.
- `(expr)`: Groups an expression.

**Twig Date**

**日付表示**

> **[date - Filters - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/filters/date.html)**
>
> Twig - The flexible, fast, and secure template engine for PHP

**Twig date\_modify**

> **[date\_modify - Filters - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/filters/date_modify.html)**
>
> Twig - The flexible, fast, and secure template engine for PHP

```auto
{{ post.published_at|date_modify("+1 day")|date("m/d/Y") }}

```

**Twig path**

> **[path - Twig Extensions Defined by Symfony (Symfony Docs)](https://symfony.com/doc/current/reference/twig_reference.html#path)**
>
> Twig is the template engine used in Symfony applications. There are tens of default filters and functions defined by Twig, but Symfony also defines some filters, functions and tags to integrate the various Symfony components with Twig templates. This...

```auto
{{ path(route_name, route_parameters = [], relative = false) }}

```

`name`

**type** : `string`

`parameters` _(optional)_

**type** : `array` **default** : `[]`

`relative` _(optional)_

**type** : `boolean` **default** : `false`

Returns the relative URL (without the scheme and host) for the given route. If `relative` is enabled, it’ll create a path relative to the current path.

### Other Operaters

> **[Other Operators - Twig for Template Designers - Documentation - Twig PHP](https://twig.symfony.com/doc/3.x/templates.html#other-operators)**
>
> The following operators don't fit into any of the other categories: | Twig - The flexible, fast, and secure template engine for PHP

- `|`: Applies a filter.

- `~` : Converts all operands into strings and concatenates them.

- `.`, `[]`: Gets an attribute of a variable.

- `?:`: The ternary operator:

- `??` : The null-coalescing operator:

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 9 月 2 日午前 7:46 UTC](https://forum.ficusonline.com/t/topic/428/7 "2021-09-02T07:46:32Z")

</div>

### Link Generatorで使用するTextクラスの漢字のローマ字変換について

以下問題と同様、リンクURLに日本語タイトルを挿入する際、ひらがなカナの読み方は正しくローマ字に変換されるが、漢字についてはピンインの読みとなってしまう。

漢字の日本語読みは複数のため、Latin規格に取り込まれていない模様。

> <https://stackoverflow.com/questions/22496164/php-transliterate-specify-locale>

**Link Generator(Blog)**

**`Website/LinkGenerator/BlogLinkGenerator.php`**

```auto
'blogtitle' => Text::toUrl($object->getTitle() ? $object->getTitle() : 'blog'),

```

**Textクラス**

**`Website/Tool/Text.php`**

```auto
public static function toUrl($text)
    {
        // to ASCII
        $text = trim(transliterator_transliterate('Any-Latin; Latin-ASCII; [^\u001F-\u007f] remove', $text));

        $search = ['?', '\'', '"', '/', '-', '+', '.', ',', ';', '(', ')', ' ', '&', 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß', 'É', 'é', 'È', 'è', 'Ê', 'ê', 'E', 'e', 'Ë', 'ë',
                         'À', 'à', 'Á', 'á', 'Å', 'å', 'a', 'Â', 'â', 'Ã', 'ã', 'ª', 'Æ', 'æ', 'C', 'c', 'Ç', 'ç', 'C', 'c', 'Í', 'í', 'Ì', 'ì', 'Î', 'î', 'Ï', 'ï',
                         'Ó', 'ó', 'Ò', 'ò', 'Ô', 'ô', 'º', 'Õ', 'õ', 'Œ', 'O', 'o', 'Ø', 'ø', 'Ú', 'ú', 'Ù', 'ù', 'Û', 'û', 'U', 'u', 'U', 'u', 'Š', 'š', 'S', 's',
                         'Ž', 'ž', 'Z', 'z', 'Z', 'z', 'L', 'l', 'N', 'n', 'Ñ', 'ñ', '¡', '¿', 'Ÿ', 'ÿ', '_', ':' ];
        $replace = ['', '', '', '', '-', '', '', '-', '-', '', '', '-', '', 'ae', 'oe', 'ue', 'Ae', 'Oe', 'Ue', 'ss', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e',
                         'A', 'a', 'A', 'a', 'A', 'a', 'a', 'A', 'a', 'A', 'a', 'a', 'AE', 'ae', 'C', 'c', 'C', 'c', 'C', 'c', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i',
                         'O', 'o', 'O', 'o', 'O', 'o', 'o', 'O', 'o', 'OE', 'O', 'o', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'S', 's', 'S', 's',
                         'Z', 'z', 'Z', 'z', 'Z', 'z', 'L', 'l', 'N', 'n', 'N', 'n', '', '', 'Y', 'y', '-', '-' ];

        $value = urlencode(str_replace($search, $replace, $text));

        return $value;
    }

```

**PHP Transliterator::transliterate**  
[https://www.php.net/manual/en/transliterator.transliterate.php](https://www.php.net/manual/en/transliterator.transliterate.php)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 9 月 3 日午前 2:43 UTC](https://forum.ficusonline.com/t/topic/428/8 "2021-09-03T02:43:19Z")

</div>

## Font-Family

> **[font-family - CSS | MDN](https://developer.mozilla.org/ja/docs/Web/CSS/Reference/Properties/font-family)**
>
> font-family は CSS のプロパティで、選択した要素に対して、フォントファミリー名や一般ファミリー名の優先順位リストを指定することができます。

**`system-ui`**

> 指定されたプラットフォームの既定のユーザーインターフェイスフォントからグリフを取ります。文字の伝統は世界で様々であるため、この総称は他の総称にきれいに一致しない文字フォントを提供します。

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 9 月 3 日午前 11:59 UTC](https://forum.ficusonline.com/t/topic/428/9 "2021-09-03T11:59:08Z")

</div>

## PImcore(Symfony)のデバッグモード

[https://pimcore.com/docs/pimcore/current/Development\_Documentation/Development\_Tools\_and\_Details/Debugging.html](https://pimcore.com/docs/pimcore/current/Development_Documentation/Development_Tools_and_Details/Debugging.html)

`.env` ファイルにより、 **Symfony** によるデバックと **Pimcore** によるデバックを別々に設定可能です。

**Symfonyによるデバックモード**

> `APP_ENV=dev`

**注** ）Symfonyのデバックモードの場合、サイト下部にデバックメニューが表示されるため、本番環境移行の際にはSymfonyのデバックモードを無効にする必要があります。

> `APP_ENV=prod`

> **[Configuring Symfony (Symfony Docs)](https://symfony.com/doc/5.x/configuration.html)**
>
> Configuration Files Symfony applications are configured with the files stored in the config/ directory, which has this default structure: 1 2 3 4 5 6 7 8 9 your-project/ ├�…

**Pimcoreによるデバックモード**

> `PIMCORE_DEV_MODE=true`

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 9 月 3 日午後 12:36 UTC](https://forum.ficusonline.com/t/topic/428/10 "2021-09-03T12:36:27Z")

</div>

### Logging ログファイル

PimcoreまたはSymfonyにより作成されるログファイルは `project/var/log` に作成・保存されます。  
各ログファイルは7日間アーカイブ保存されますが、Symfonyのデバックモード有効時(APP\_ENV=dev)のDEVログファイルは1日のアーカイブ容量が数百ＭBを浪費するため注意が必要です。

**Logging-Pimcore**  
[https://pimcore.com/docs/pimcore/current/Development\_Documentation/Development\_Tools\_and\_Details/Logging.html](https://pimcore.com/docs/pimcore/current/Development_Documentation/Development_Tools_and_Details/Logging.html)

**Symfony Logging**

> **[Logging (Symfony Docs)](https://symfony.com/doc/current/logging.html)**
>
> Symfony comes with two minimalist PSR-3 loggers: Logger for the HTTP context and ConsoleLogger for the CLI context. In conformance with the twelve-factor app methodology, they send messages starting f…

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 9 月 4 日午前 12:56 UTC](https://forum.ficusonline.com/t/topic/428/11 "2021-09-04T00:56:20Z")

</div>

## File Permissions

**Pimcore**  
[https://pimcore.com/docs/pimcore/current/Development\_Documentation/Installation\_and\_Upgrade/System\_Setup\_and\_Hosting/File\_Permissions.html](https://pimcore.com/docs/pimcore/current/Development_Documentation/Installation_and_Upgrade/System_Setup_and_Hosting/File_Permissions.html)

パーミッションと `bin` フォルダ内スクリプト実行権の付与

```auto
$ sudo chown -R YOURUSER:YOURGROUP var public/var
$ sudo chmod ug+x bin/*

```

**Symfony**

> **[Setting up or Fixing File Permissions (Symfony Docs)](https://symfony.com/doc/current/setup/file_permissions.html)**
>
> Symfony generates certain files in the var/ directory of your project when running the application. In the dev environment, the bin/console and public/index.php files use umask() to make sure that the…

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 9 月 4 日午前 6:05 UTC](https://forum.ficusonline.com/t/topic/428/12 "2021-09-04T06:05:26Z")

</div>

## サイトマップ (Sitemaps)

**Pimcore Sitemaps**  
[https://pimcore.com/docs/platform/Pimcore/Tools\_and\_Features/Sitemaps/](https://pimcore.com/docs/platform/Pimcore/Tools_and_Features/Sitemaps/)

> ### CAUTION
> 
> To use this feature, please enable the `PimcoreSeoBundle` in your `bundle.php` file and install it accordingly with the following command:
> 
> ```auto
> # bin/console pimcore:bundle:install PimcoreSeoBundle
> 
> ```

**PrestaSitemap Installation**

> <https://github.com/prestaconcept/PrestaSitemapBundle/blob/master/Resources/doc/1-installation.md>

**PrestaSitemap Configuration**

> <https://github.com/prestaconcept/PrestaSitemapBundle/blob/3.x/doc/2-configuration.md>

`vendor/presta` フォルダーに以下のパッケージがない場合にインストール

```auto
$ composer require presta/sitemap-bundle

```

`config/bundles.php` に以下追加

```auto
<?php
return [
    //...
    Presta\SitemapBundle\PrestaSitemapBundle::class => ['all' => true],
];

```

上記パッケージの設定ファイルをインポート  
`config/routes/presta_sitemap.yaml`

```auto
presta_sitemap:
    resource: "@PrestaSitemapBundle/Resources/config/routing.yml"
    prefix: /

```

カスタム設定  
`config/packages/presta_sitemap.yaml`

```auto
presta_sitemap:
    alternate:
        enabled: true
        default_locale: 'en'
        locales: ['en', 'ja']
        i18n: symfony

```

キャッシュクリアと所有権修復

```bash
# bin/console cache:clear
# chown -R www-data:www-data ./

```

サイトマップのアウトプット

```auto
# bin/console presta:sitemaps:dump --base-url=https://ficus.myvnc.com/
Dumping all sections of sitemaps into public directory
Created/Updated the following sitemap files:
    sitemap.default.xml
    sitemap.xml

```

* * *

**robots.txtの作成**

> **[robots.txt の書き方、設定と送信 | Google のクロール インフラストラクチャ  |  Crawling infrastructure...](https://developers.google.com/crawling/docs/robots-txt/create-robots-txt?hl=ja)**
>
> robots.txt ファイルはサイトのルートにあります。robots.txt ファイルの作成方法、例、robots.txt のルールを紹介します。

**About /robots.txt**

> **[The Web Robots Pages](https://www.robotstxt.org/robotstxt.html)**

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 9 月 4 日午後 2:54 UTC](https://forum.ficusonline.com/t/topic/428/13 "2021-09-04T14:54:48Z")

</div>

## global.cssの変更

**`/public/static/css/global.css`**

**表示サイズ変更時の不具合**

新規オブジェクト内で定義した **wysiwyg** によるテキスト要素内で追加した画像サイズが、携帯モードにしてもそのまま。  
ウェブページ表示内の画像サイズを携帯サイズの幅にも対応させるため `global.css` に以下追加。

```auto
.main-content img {
    max-width: 100%;
}

```

### CKEditor Code Snippetの背景カラー

携帯幅サイズへ変更時、カーソルが付与されたセクションでカーソルを右移動すると背景が白のまま（cssでの指定背景色が反映されていない）。  
**codesnippet** 指定セクション `<pre><code>.....</code></pre>`

**`<pre>`セクション** で以下指定。

```auto
pre {
    display: block;
    padding: 10px;
    margin: 0 0 10.5px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-all;
    word-wrap: break-word;
    color: #7b8a8b;
    background-color: #474948;
    border: 1px solid #ffffff;
    border-radius: 4px;
}

```

**URLの改行**

表示幅縮小時の **`https://............`** の改行指定

```auto
a {
    overflow-wrap: break-word;
}

```

**overflow-wrap無効時**

 ![overflow-wrap-deactive](https://forum.ficusonline.com/uploads/default/original/1X/8599e1b81e427718302e62cbdde620754b106731.png)

**overflow-wrap有効時**

 ![overflow-wrap-active](https://forum.ficusonline.com/uploads/default/original/1X/4a8a62413266819e3ee9364369d083c10defb22b.png)

**overflow-wrap**

> **[overflow-wrap - CSS | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/overflow-wrap)**
>
> The overflow-wrap CSS property applies to text, setting whether the browser should insert line breaks within an otherwise unbreakable string to prevent text from overflowing its line box.

**word-break**

> **[word-break - CSS | MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/word-break)**
>
> The word-break CSS property sets whether line breaks appear wherever the text would otherwise overflow its content box.

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 9 月 27 日午前 5:43 UTC](https://forum.ficusonline.com/t/topic/428/14 "2021-09-27T05:43:43Z")

</div>

### Error Redirect Page

**指定URIエラー時のリダイレクト**

**Error-Page** を作成し、そのディレクトリを指定。

`System Settings ---> Website`

 ![error_redirect](https://forum.ficusonline.com/uploads/default/original/1X/57f53f7377bd3a7a0477cf6424f9b21c45f3cf33.png)

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 11 月 6 日午前 8:49 UTC](https://forum.ficusonline.com/t/topic/428/15 "2021-11-06T08:49:43Z")

</div>

## AWSへ移行時のエラー

500エラー発生。.envでデバックモードへ変更し下記エラー確認。Documentページの読み込みエラー。

`PLUGIN_CMF_COLLECT_DOCUMENT_SEGMENT_ASSIGNMENTS(?)' with params [1]:`

下記問題と同一

> <https://github.com/pimcore/demo/issues/142>
>
> Front end crashes with fresh, clean installation of the demo:
> 
> Doctrine\\DBAL\\E…xception\\DriverException:
> An exception occurred while executing 'SELECT PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS(?)' with params \[1\]:
> 
> SQLSTATE\[42000\]: Syntax error or access violation: 1305 FUNCTION newdemo.PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS does not exist
> 
> at vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:106
> at Doctrine\\DBAL\\Driver\\AbstractMySQLDriver-\>convertException('An exception occurred while executing \\'SELECT PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS(?)\\' with params \[1\]:SQLSTATE\[42000\]: Syntax error or access violation: 1305 FUNCTION newdemo.PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS does not exist', object(PDOException))
> (vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:169)
> at Doctrine\\DBAL\\DBALException::wrapException(object(Driver), object(PDOException), 'An exception occurred while executing \\'SELECT PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS(?)\\' with params \[1\]:SQLSTATE\[42000\]: Syntax error or access violation: 1305 FUNCTION newdemo.PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS does not exist')
> (vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:145)
> at Doctrine\\DBAL\\DBALException::driverExceptionDuringQuery(object(Driver), object(PDOException), 'SELECT PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS(?)', array(1))
> (vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:911)
> at Doctrine\\DBAL\\Connection-\>executeQuery('SELECT PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS(?)', array(1), array(2), null)
> (vendor/pimcore/pimcore/lib/Db/PimcoreExtensionsTrait.php:93)
> at Pimcore\\Db\\Connection-\>executeQuery('SELECT PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS(:elementId)', array('elementId' =\> 1), array())
> (vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:578)
> at Doctrine\\DBAL\\Connection-\>fetchColumn('SELECT PLUGIN\_CMF\_COLLECT\_DOCUMENT\_SEGMENT\_ASSIGNMENTS(:elementId)', array('elementId' =\> 1))
> (vendor/pimcore/customer-management-framework-bundle/src/SegmentAssignment/StoredFunctions/DefaultStoredFunctions.php:24)
> at CustomerManagementFrameworkBundle\\SegmentAssignment\\StoredFunctions\\DefaultStoredFunctions-\>retrieve('1', 'document')
> (vendor/pimcore/customer-management-framework-bundle/src/SegmentManager/DefaultSegmentManager.php:159)
> at CustomerManagementFrameworkBundle\\SegmentManager\\DefaultSegmentManager-\>getSegmentsForElementId('1', 'document')
> (vendor/pimcore/customer-management-framework-bundle/src/SegmentManager/DefaultSegmentManager.php:151)
> at CustomerManagementFrameworkBundle\\SegmentManager\\DefaultSegmentManager-\>getSegmentsForElement(object(Page))
> (vendor/pimcore/customer-management-framework-bundle/src/Targeting/EventListener/ElementSegmentsListener.php:111)
> at CustomerManagementFrameworkBundle\\Targeting\\EventListener\\ElementSegmentsListener-\>trackDocumentSegments(object(TargetingResolveVisitorInfoEvent))
> (vendor/pimcore/customer-management-framework-bundle/src/Targeting/EventListener/ElementSegmentsListener.php:76)
> at CustomerManagementFrameworkBundle\\Targeting\\EventListener\\ElementSegmentsListener-\>onTargetingPreResolve(object(TargetingResolveVisitorInfoEvent), 'pimcore.targeting.pre\_resolve', object(TraceableEventDispatcher))
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:126)
> at Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener-\>\_\_invoke(object(TargetingResolveVisitorInfoEvent), 'pimcore.targeting.pre\_resolve', object(TraceableEventDispatcher))
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:260)
> at Symfony\\Component\\EventDispatcher\\EventDispatcher-\>doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'pimcore.targeting.pre\_resolve', object(TargetingResolveVisitorInfoEvent))
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:235)
> at Symfony\\Component\\EventDispatcher\\EventDispatcher-\>callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'pimcore.targeting.pre\_resolve', object(TargetingResolveVisitorInfoEvent))
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:73)
> at Symfony\\Component\\EventDispatcher\\EventDispatcher-\>dispatch(object(TargetingResolveVisitorInfoEvent), 'pimcore.targeting.pre\_resolve')
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:168)
> at Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher-\>dispatch(object(TargetingResolveVisitorInfoEvent), object(TargetingResolveVisitorInfoEvent))
> (vendor/pimcore/pimcore/lib/Targeting/VisitorInfoResolver.php:110)
> at Pimcore\\Targeting\\VisitorInfoResolver-\>resolve(object(Request))
> (vendor/pimcore/pimcore/lib/Targeting/EventListener/TargetingListener.php:137)
> at Pimcore\\Targeting\\EventListener\\TargetingListener-\>onKernelRequest(object(RequestEvent), 'kernel.request', object(TraceableEventDispatcher))
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:126)
> at Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener-\>\_\_invoke(object(RequestEvent), 'kernel.request', object(TraceableEventDispatcher))
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:260)
> at Symfony\\Component\\EventDispatcher\\EventDispatcher-\>doDispatch(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(RequestEvent))
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:235)
> at Symfony\\Component\\EventDispatcher\\EventDispatcher-\>callListeners(array(object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener), object(WrappedListener)), 'kernel.request', object(RequestEvent))
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:73)
> at Symfony\\Component\\EventDispatcher\\EventDispatcher-\>dispatch(object(RequestEvent), 'kernel.request')
> (vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php:168)
> at Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher-\>dispatch(object(RequestEvent), 'kernel.request')
> (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:127)
> at Symfony\\Component\\HttpKernel\\HttpKernel-\>handleRaw(object(Request), 1)
> (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
> at Symfony\\Component\\HttpKernel\\HttpKernel-\>handle(object(Request), 1, true)
> (vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:198)
> at Symfony\\Component\\HttpKernel\\Kernel-\>handle(object(Request))
> (web/app.php:36)
> 
> Environment:
> Current OS X, MySQL, Symfony dev server

[https://github.com/pimcore/customer-data-framework/blob/3.x/src/Resources/sql/segmentAssignment/storedFunctionDocument.sql](https://github.com/pimcore/customer-data-framework/blob/3.x/src/Resources/sql/segmentAssignment/storedFunctionDocument.sql)

```auto
DROP FUNCTION IF EXISTS PLUGIN_CMF_COLLECT_DOCUMENT_SEGMENT_ASSIGNMENTS;
DELIMITER //

CREATE FUNCTION PLUGIN_CMF_COLLECT_DOCUMENT_SEGMENT_ASSIGNMENTS(elementIdent INT) RETURNS TEXT
  READS SQL DATA
  BEGIN
    DECLARE segmentIds TEXT;
    DECLARE elementExists TINYINT;
    DECLARE breaks TINYINT;

    SELECT `segments` FROM `plugin_cmf_segment_assignment` WHERE `elementId` = elementIdent AND `elementType` = 'document' INTO segmentIds;
    SELECT COUNT(*) FROM `plugin_cmf_segment_assignment` WHERE `elementId` = elementIdent AND `elementType` = 'document' INTO elementExists;
    SELECT `breaksInheritance` FROM `plugin_cmf_segment_assignment` WHERE `elementId` = elementIdent AND `elementType` = 'document' INTO breaks;

    WHILE (elementExists = 0 OR breaks IS NULL OR breaks <> 1) AND elementIdent > 1 DO
      SELECT `parentId` FROM `documents` WHERE `id` = elementIdent INTO elementIdent;
      SELECT CONCAT_WS(',', segmentIds, (SELECT `segments` FROM `plugin_cmf_segment_assignment` WHERE `elementId` = elementIdent AND `elementType` = 'document')) INTO segmentIds;
      SELECT COUNT(*) FROM `plugin_cmf_segment_assignment` WHERE `elementId` = elementIdent AND `elementType` = 'document' INTO elementExists;
      SELECT `breaksInheritance` INTO breaks FROM `plugin_cmf_segment_assignment` WHERE `elementId` = elementIdent AND `elementType` = 'document';
    END WHILE;

    RETURN segmentIds;
  END//
DELIMITER ;

```

上記sqlコマンドをpimcoreのデータベースで実行。

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 11 月 10 日午前 10:59 UTC](https://forum.ficusonline.com/t/topic/428/17 "2021-11-10T10:59:46Z")

</div>

## GmailによるMailer設定

**Pimcore** で使用する **Mailer** を **Gmail** に設定します。

**PImcoreEmail Framework**  
[https://pimcore.com/docs/pimcore/current/Development\_Documentation/Development\_Tools\_and\_Details/Email\_Framework/](https://pimcore.com/docs/pimcore/current/Development_Documentation/Development_Tools_and_Details/Email_Framework/)

**参照元：Symfony** の **Mailer** に関するドキュメント

> **[Sending Emails with Mailer (Symfony Docs)](https://symfony.com/doc/5.x/mailer.html)**
>
> Installation Symfony's Mailer & Mime components form a powerful system for creating and sending emails - complete with support for multipart messages, Twig integration, CSS inlining, file attachme…

以下 **PImcore** の設定ファイルの **Mailer** の箇所をアンコメントして有効にして下さい。

`config/config.yml`

```auto
#### SYSTEM SETTINGS

    email:
        sender:
            name: 'Ficusonline'
            email: ficus.online@gmail.com
        return:
            name: ''
            email: ''

#### SYMFONY OVERRIDES
framework:

#### SYMFONY MAILER TRANSPORTS
    mailer:
        transports:
            main: '%env(MAILER_DSN)%'

```

GmailによるMailer設定は、別途 `.env` ファイルで指定。  
`.env`

```auto
MAILER_DSN=gmail+smtp://USERNAME:PASSWORD@default

```

**Composer** で **Gmail Mailer** をインストール。

```auto
# composer require symfony/google-mailer

```

最後に **Pimcore** によるサイトディレクトリのアクセス権 **（500error対応）** を修復して下さい。

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 11 月 20 日午前 5:30 UTC](https://forum.ficusonline.com/t/topic/428/18 "2021-11-20T05:30:35Z")

</div>

## bin/console command

**キャッシュクリア**

```auto
# bin/console cache:clear

```

キャッシュクリア後はアクセス権を見直すこと。

```bash
# chown -R www-data:www-data ./

```

**コマンドオプション一覧**

```auto
# bin/console
Pimcore 10.0.8 (env: prod, debug: false)

Usage:
  command [options] [arguments]

Options:
  -h, --help Display help for the given command. When no command is given display help for the list command
  -q, --quiet Do not output any message
  -V, --version Display this application version
      --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
  -n, --no-interaction Do not ask any interactive question
      --ignore-maintenance-mode Set this flag to force execution in maintenance mode
      --maintenance-mode Set this flag to force maintenance mode while this task runs
  -e, --env=ENV The Environment name. [default: "prod"]
      --no-debug Switch off debug mode.
  -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  about Display information about the current project
  help Display help for a command
  list List commands
 app
  app:asset-copyright                               
  app:data-command                                  
 assets
  assets:install Install bundle's web assets under a public directory
 cache
  cache:clear Clear the cache
  cache:pool:clear Clear cache pools
  cache:pool:delete Delete an item from a cache pool
  cache:pool:list List available cache pools
  cache:pool:prune Prune cache pools
  cache:warmup Warm up an empty cache
 cmf
  cmf:build-segments Build automatically calculated segments
  cmf:duplicates-index Handles the duplicate search index
  cmf:handle-cron-triggers Handle cron triggers cronjob - needs to run once per minute
  cmf:maintenance Performs various tasks configured in services.yml -> 'cmf.maintenance.serviceCalls'
  cmf:process-actiontrigger-queue Process entries from action trigger queue
  cmf:segment-assignment-index Processes entries from segment assignment queue, use this for manually updating the index, which is usually done during cmf:maintenance
 config
  config:dump-reference Dump the default configuration for an extension
 datahub
  datahub:graphql:rebuild-definitions Rebuild GraphQL endpoint definitions
 dbal
  dbal:run-sql Executes arbitrary SQL directly from the command line.
 debug
  debug:autowiring List classes/interfaces you can use for autowiring
  debug:config Dump the current configuration for an extension
  debug:container Display current services for an application
  debug:event-dispatcher Display configured listeners for an application
  debug:firewall Display information about your security firewall(s)
  debug:form Display form type information
  debug:router Display current routes for an application
  debug:translation Display translation messages information
  debug:twig Show a list of twig functions, filters, globals and tests
  debug:validator Display validation constraints for classes
 doctrine
  doctrine:database:create Creates the configured database
  doctrine:database:drop Drops the configured database
  doctrine:database:import Import SQL file(s) directly to Database.
  doctrine:migrations:current [current] Outputs the current version
  doctrine:migrations:diff [diff] Generate a migration by comparing your current database to your mapping information.
  doctrine:migrations:dump-schema [dump-schema] Dump the schema for your database to a migration.
  doctrine:migrations:execute [execute] Execute one or more migration versions up or down manually.
  doctrine:migrations:generate [generate] Generate a blank migration class.
  doctrine:migrations:latest [latest] Outputs the latest version
  doctrine:migrations:list [list-migrations] Display a list of all available migrations and their status.
  doctrine:migrations:migrate [migrate] Execute a migration to a specified version or the latest available version.
  doctrine:migrations:rollup [rollup] Rollup migrations by deleting all tracked versions and insert the one version that exists.
  doctrine:migrations:status [status] View the status of a set of migrations.
  doctrine:migrations:sync-metadata-storage [sync-metadata-storage] Ensures that the metadata storage is at the latest version.
  doctrine:migrations:up-to-date [up-to-date] Tells you if your schema is up-to-date.
  doctrine:migrations:version [version] Manually add and delete migration versions from the version table.
  doctrine:query:sql Executes arbitrary SQL directly from the command line.
 ecommerce
  ecommerce:cleanup-pending-orders Cleans up orders with state pending payment after 1h -> delegates this to commit order processor
  ecommerce:indexservice:bootstrap Bootstrap tasks creating/updating index (for all tenants), use one of the options --create-or-update-index-structure or --update-index
  ecommerce:indexservice:elasticsearch-sync Refresh elastic search (ES) index settings, mappings via native ES-API.
  ecommerce:indexservice:process-preparation-queue Processes the ecommerce preparation queue based on the store table(s).
  ecommerce:indexservice:process-update-queue Processes the ecommerce queue / store table and updates the (search) index.
  ecommerce:indexservice:reset-queue Resets the preparation or index-update queue (ONLY NEEDED if store table is out of sync)
  ecommerce:voucher:cleanup-reservations Cleans the token reservations due to sysConfig duration settings
  ecommerce:voucher:cleanup-statistics House keeping for Voucher Usage Statistics - cleans up all old data.
 fos
  fos:js-routing:debug Displays currently exposed routes for an application
  fos:js-routing:dump Dumps exposed routes to the filesystem
 lint
  lint:container Ensure that arguments injected into services match type declarations
  lint:twig Lint a Twig template and outputs encountered errors
  lint:xliff Lint an XLIFF file and outputs encountered errors
  lint:yaml Lint a YAML file and outputs encountered errors
 pimcore
  pimcore:bundle:disable Disables a bundle
  pimcore:bundle:enable Enables a bundle
  pimcore:bundle:install Installs a bundle
  pimcore:bundle:list Lists all pimcore bundles and their enabled/installed state
  pimcore:bundle:uninstall Uninstalls a bundle
  pimcore:cache:clear Clear caches
  pimcore:cache:warming Warm up caches
  pimcore:classificationstore:delete-store [classificationstore:delete-store] Delete Classification Store
  pimcore:definition:import:class [definition:import:class] Import Class definition from a JSON export
  pimcore:definition:import:customlayout [definition:import:customlayout] Import Customlayout definition from a JSON export
  pimcore:definition:import:fieldcollection [definition:import:fieldcollection] Import FieldCollection definition from a JSON export
  pimcore:definition:import:objectbrick [definition:import:objectbrick] Import ObjectBrick definition from a JSON export
  pimcore:deployment:classes-rebuild [deployment:classes-rebuild] rebuilds db structure for classes, field collections and object bricks based on updated var/classes/definition_*.php files
  pimcore:deployment:custom-layouts-rebuild rebuilds db structure for custom layouts based on updated var/classes/customlayouts/definition_*.php files
  pimcore:documents:generate-page-previews Generates the previews shown in the tree on hover
  pimcore:documents:migrate-elements Migrates document elements to editables. See issue https://github.com/pimcore/pimcore/issues/7384 first
  pimcore:email:cleanup [email:cleanup] Cleanup email logs
  pimcore:image:low-quality-preview [pimcore:image:svg-preview] Regenerates low quality image previews for all image assets
  pimcore:locale:delete-unused-tables Delete unused locale(invalid language) tables & views
  pimcore:maintenance [maintenance] Asynchronous maintenance jobs of pimcore (needs to be set up as cron job)
  pimcore:maintenance-mode Enable or disable maintenance mode
  pimcore:mysql-tools [mysql-tools] Optimize and warmup mysql database
  pimcore:run-script Run a specific PHP script in an initialized Pimcore environment
  pimcore:search-backend-reindex [search-backend-reindex] Re-indexes the backend search of pimcore
  pimcore:system:requirements:check [system:requirements:check] Check system requirements
  pimcore:thumbnails:clear Clear certain image or video thumbnails (temp. files)
  pimcore:thumbnails:image [thumbnails:image] Generate image thumbnails, useful to pre-generate thumbnails in the background
  pimcore:thumbnails:optimize-images [thumbnails:optimize-images] Optimize filesize of all thumbnails
  pimcore:thumbnails:video [thumbnails:video] Generate video thumbnails, useful to pre-generate thumbnails in the background
  pimcore:user:reset-password [reset-password] Reset a user's password
  pimcore:web2print:pdf-creation [web2print:pdf-creation] Start pdf creation
  pimcore:workflow:dump Dump a workflow
 presta
  presta:sitemaps:dump Dumps sitemaps to given location
 router
  router:match Help debug routes by simulating a path info match
 secrets
  secrets:decrypt-to-local Decrypt all secrets and stores them in the local vault
  secrets:encrypt-from-local Encrypt all local secrets to the vault
  secrets:generate-keys Generate new encryption keys
  secrets:list List all secrets
  secrets:remove Remove a secret from the vault
  secrets:set Set a secret in the vault
 security
  security:encode-password Encode a password
  security:hash-password Hash a user password
 translation
  translation:pull Pull translations from a given provider.
  translation:push Push translations to a given provider.
  translation:update Update the translation file

```

### Pimcore設定確認

```auto
# bin/console debug:config pimcore

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 11 月 25 日午前 8:02 UTC](https://forum.ficusonline.com/t/topic/428/20 "2021-11-25T08:02:32Z")

</div>

## Pimcore bundleの無効化

以下イーコマース関連のbundleは不要のため無効とする。

- **PimcoreCustomerManagementFrameworkBundle**
- **PimcoreEcommerceFrameworkBundle**
- **PimcorePaymentProviderUnzerBundle**

以下 **bin/console** コマンドオプションにて **bundleリスト** を確認後無効化。

```auto
pimcore
  pimcore:bundle:disable Disables a bundle
  pimcore:bundle:enable Enables a bundle
  pimcore:bundle:install Installs a bundle
  pimcore:bundle:list Lists all pimcore bundles and their enabled/installed state
  pimcore:bundle:uninstall Uninstalls a bundle
  pimcore:cache:clear Clear caches

```

```auto
# ./bin/console pimcore:bundle:list
+------------------------------------------+---------+-----------+-------------+---------------+----------+---+
| Bundle | Enabled | Installed | Installable | Uninstallable | Priority | |
+------------------------------------------+---------+-----------+-------------+---------------+----------+---+
| PimcoreCustomerManagementFrameworkBundle | ❌ | ❌ | ❌ | ❌ | ❌ | 0 |
| OutputDataConfigToolkitBundle | ✔ | ❌ | ✔ | ✔ | ✔ | |
| PimcoreDataHubBundle | ✔ | ✔ | ❌ | ❌ | ✔ | |
| PimcoreEcommerceFrameworkBundle | ❌ | ❌ | ❌ | ❌ | ❌ | 0 |
| PimcorePaymentProviderUnzerBundle | ❌ | ❌ | ❌ | ❌ | ❌ | 0 |
| NumberSequenceGeneratorBundle | ❌ | ❌ | ❌ | ❌ | ❌ | 0 |
| ObjectMergerBundle | ✔ | ✔ | ❌ | ❌ | ✔ | |
| Web2PrintToolsBundle | ✔ | ❌ | ✔ | ❌ | ✔ | |
+------------------------------------------+---------+-----------+-------------+---------------+----------+---+

```

無効化

```auto
# ./bin/console pimcore:bundle:disable PimcorePaymentProviderUnzerBundle

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2021 年 11 月 29 日午後 1:01 UTC](https://forum.ficusonline.com/t/topic/428/21 "2021-11-29T13:01:13Z")

</div>

### Data Objects 500 Error

バージョン履歴のクリア

> [@Pimcoreバックアップ（履歴データのクリア）](https://forum.ficusonline.com/t/pimcore/180#cleanup-data-storage-1):
>
> バックアップを実行する前に、 Cleanup Data Storage ドキュメント、オブジェクト、アセットのバージョンクリーンアップ [https://pimcore.com/docs/pimcore/current/Development\_Documentation/Administration\_of\_Pimcore/Cleanup\_Data\_Storage.html](https://pimcore.com/docs/pimcore/current/Development_Documentation/Administration_of_Pimcore/Cleanup_Data_Storage.html) # ./bin/co…

phpMyAdminのpimcoreデータベース内で以下sqlコマンド実行

```auto
DELETE FROM ###.versions WHERE ctype='asset';

```

全バージョン履歴のクリア

```auto
$ docker exec -ti pimcore10-fpm bash
# cd pimcore10
# ./bin/console pimcore:maintenance -f -j versioncleanup
# rm -r var/versions/object

```

---

<div class="post-metadata">

### Author: ![tk-fuse](https://forum.ficusonline.com/user_avatar/forum.ficusonline.com/tk-fuse/32/255_2.png) [@tk-fuse](https://forum.ficusonline.com/u/tk-fuse)
#### Post date: [2022 年 3 月 11 日午後 11:19 UTC](https://forum.ficusonline.com/t/topic/428/22 "2022-03-11T23:19:22Z")

</div>

## 管理画面エラー

**ブラウザの検証メッセージ**  
`pimcore_admin_document_document_doctypesget error on admin`

> **[pimcore\_admin\_document\_document\_doctypesget error on admin · pimcore ·...](https://github.com/orgs/pimcore/discussions/8814)**
>
> Hi, after deploying new/changed stuff from dev to test-env, I got error from backend. I see login-page for admin. After login I get: I deployed with: git pull composer install bin/console pimcore:d...

デバックモードへ変更し管理画面へのログイン可否確認後、プロダクションモードへ変更。  
キャッシュの不具合によるエラー。

```auto
# bin/console clear:cache

```

**bin/console list**

```auto
bin/console list       
Pimcore 10.0.8 (env: prod, debug: false)

Usage:
  command [options] [arguments]

Options:
  -h, --help Display help for the given command. When no command is given display help for the list command
  -q, --quiet Do not output any message
  -V, --version Display this application version
      --ansi|--no-ansi Force (or disable --no-ansi) ANSI output
  -n, --no-interaction Do not ask any interactive question
      --ignore-maintenance-mode Set this flag to force execution in maintenance mode
      --maintenance-mode Set this flag to force maintenance mode while this task runs
  -e, --env=ENV The Environment name. [default: "prod"]
      --no-debug Switch off debug mode.
  -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  about Display information about the current project
  help Display help for a command
  list List commands
 app
  app:asset-copyright                               
  app:data-command                                  
 assets
  assets:install Install bundle's web assets under a public directory
 cache
  cache:clear Clear the cache
  cache:pool:clear Clear cache pools
  cache:pool:delete Delete an item from a cache pool
  cache:pool:list List available cache pools
  cache:pool:prune Prune cache pools
  cache:warmup Warm up an empty cache
 cmf
  cmf:build-segments Build automatically calculated segments
  cmf:duplicates-index Handles the duplicate search index
  cmf:handle-cron-triggers Handle cron triggers cronjob - needs to run once per minute
  cmf:maintenance Performs various tasks configured in services.yml -> 'cmf.maintenance.serviceCalls'
  cmf:process-actiontrigger-queue Process entries from action trigger queue
  cmf:segment-assignment-index Processes entries from segment assignment queue, use this for manually updating the index, which is usually done during cmf:maintenance
 config
  config:dump-reference Dump the default configuration for an extension
 datahub
  datahub:graphql:rebuild-definitions Rebuild GraphQL endpoint definitions
 dbal
  dbal:run-sql Executes arbitrary SQL directly from the command line.
 debug
  debug:autowiring List classes/interfaces you can use for autowiring
  debug:config Dump the current configuration for an extension
  debug:container Display current services for an application
  debug:event-dispatcher Display configured listeners for an application
  debug:firewall Display information about your security firewall(s)
  debug:form Display form type information
  debug:router Display current routes for an application
  debug:translation Display translation messages information
  debug:twig Show a list of twig functions, filters, globals and tests
  debug:validator Display validation constraints for classes
 doctrine
  doctrine:database:create Creates the configured database
  doctrine:database:drop Drops the configured database
  doctrine:database:import Import SQL file(s) directly to Database.
  doctrine:migrations:current [current] Outputs the current version
  doctrine:migrations:diff [diff] Generate a migration by comparing your current database to your mapping information.
  doctrine:migrations:dump-schema [dump-schema] Dump the schema for your database to a migration.
  doctrine:migrations:execute [execute] Execute one or more migration versions up or down manually.
  doctrine:migrations:generate [generate] Generate a blank migration class.
  doctrine:migrations:latest [latest] Outputs the latest version
  doctrine:migrations:list [list-migrations] Display a list of all available migrations and their status.
  doctrine:migrations:migrate [migrate] Execute a migration to a specified version or the latest available version.
  doctrine:migrations:rollup [rollup] Rollup migrations by deleting all tracked versions and insert the one version that exists.
  doctrine:migrations:status [status] View the status of a set of migrations.
  doctrine:migrations:sync-metadata-storage [sync-metadata-storage] Ensures that the metadata storage is at the latest version.
  doctrine:migrations:up-to-date [up-to-date] Tells you if your schema is up-to-date.
  doctrine:migrations:version [version] Manually add and delete migration versions from the version table.
  doctrine:query:sql Executes arbitrary SQL directly from the command line.
 ecommerce
  ecommerce:cleanup-pending-orders Cleans up orders with state pending payment after 1h -> delegates this to commit order processor
  ecommerce:indexservice:bootstrap Bootstrap tasks creating/updating index (for all tenants), use one of the options --create-or-update-index-structure or --update-index
  ecommerce:indexservice:elasticsearch-sync Refresh elastic search (ES) index settings, mappings via native ES-API.
  ecommerce:indexservice:process-preparation-queue Processes the ecommerce preparation queue based on the store table(s).
  ecommerce:indexservice:process-update-queue Processes the ecommerce queue / store table and updates the (search) index.
  ecommerce:indexservice:reset-queue Resets the preparation or index-update queue (ONLY NEEDED if store table is out of sync)
  ecommerce:voucher:cleanup-reservations Cleans the token reservations due to sysConfig duration settings
  ecommerce:voucher:cleanup-statistics House keeping for Voucher Usage Statistics - cleans up all old data.
 fos
  fos:js-routing:debug Displays currently exposed routes for an application
  fos:js-routing:dump Dumps exposed routes to the filesystem
 lint
  lint:container Ensure that arguments injected into services match type declarations
  lint:twig Lint a Twig template and outputs encountered errors
  lint:xliff Lint an XLIFF file and outputs encountered errors
  lint:yaml Lint a YAML file and outputs encountered errors
 pimcore
  pimcore:bundle:disable Disables a bundle
  pimcore:bundle:enable Enables a bundle
  pimcore:bundle:install Installs a bundle
  pimcore:bundle:list Lists all pimcore bundles and their enabled/installed state
  pimcore:bundle:uninstall Uninstalls a bundle
  pimcore:cache:clear Clear caches
  pimcore:cache:warming Warm up caches
  pimcore:classificationstore:delete-store [classificationstore:delete-store] Delete Classification Store
  pimcore:definition:import:class [definition:import:class] Import Class definition from a JSON export
  pimcore:definition:import:customlayout [definition:import:customlayout] Import Customlayout definition from a JSON export
  pimcore:definition:import:fieldcollection [definition:import:fieldcollection] Import FieldCollection definition from a JSON export
  pimcore:definition:import:objectbrick [definition:import:objectbrick] Import ObjectBrick definition from a JSON export
  pimcore:deployment:classes-rebuild [deployment:classes-rebuild] rebuilds db structure for classes, field collections and object bricks based on updated var/classes/definition_*.php files
  pimcore:deployment:custom-layouts-rebuild rebuilds db structure for custom layouts based on updated var/classes/customlayouts/definition_*.php files
  pimcore:documents:generate-page-previews Generates the previews shown in the tree on hover
  pimcore:documents:migrate-elements Migrates document elements to editables. See issue https://github.com/pimcore/pimcore/issues/7384 first
  pimcore:email:cleanup [email:cleanup] Cleanup email logs
  pimcore:image:low-quality-preview [pimcore:image:svg-preview] Regenerates low quality image previews for all image assets
  pimcore:locale:delete-unused-tables Delete unused locale(invalid language) tables & views
  pimcore:maintenance [maintenance] Asynchronous maintenance jobs of pimcore (needs to be set up as cron job)
  pimcore:maintenance-mode Enable or disable maintenance mode
  pimcore:mysql-tools [mysql-tools] Optimize and warmup mysql database
  pimcore:run-script Run a specific PHP script in an initialized Pimcore environment
  pimcore:search-backend-reindex [search-backend-reindex] Re-indexes the backend search of pimcore
  pimcore:system:requirements:check [system:requirements:check] Check system requirements
  pimcore:thumbnails:clear Clear certain image or video thumbnails (temp. files)
  pimcore:thumbnails:image [thumbnails:image] Generate image thumbnails, useful to pre-generate thumbnails in the background
  pimcore:thumbnails:optimize-images [thumbnails:optimize-images] Optimize filesize of all thumbnails
  pimcore:thumbnails:video [thumbnails:video] Generate video thumbnails, useful to pre-generate thumbnails in the background
  pimcore:user:reset-password [reset-password] Reset a user's password
  pimcore:web2print:pdf-creation [web2print:pdf-creation] Start pdf creation
  pimcore:workflow:dump Dump a workflow
 presta
  presta:sitemaps:dump Dumps sitemaps to given location
 router
  router:match Help debug routes by simulating a path info match
 secrets
  secrets:decrypt-to-local Decrypt all secrets and stores them in the local vault
  secrets:encrypt-from-local Encrypt all local secrets to the vault
  secrets:generate-keys Generate new encryption keys
  secrets:list List all secrets
  secrets:remove Remove a secret from the vault
  secrets:set Set a secret in the vault
 security
  security:encode-password Encode a password
  security:hash-password Hash a user password
 translation
  translation:pull Pull translations from a given provider.
  translation:push Push translations to a given provider.
  translation:update Update the translation file

```

[次のページ](https://forum.ficusonline.com/t/topic/428.md?page=2)
