「基本からしっかり学ぶ Symfony2 入門」メモ(3)

「基本からしっかり学ぶ Symfony2 入門」を買った。

基本からしっかり学ぶ Symfony2入門

基本からしっかり学ぶ Symfony2入門

基本からしっかり学ぶ Symfony2入門:書籍案内|技術評論社

hidenorigoto/symfony2-book: 基本からしっかり学ぶSymfony2入門 サポートサイト

Writer::createFromStringの引数について

前回、Write::createFromString('', '')の引数は2つだったと書いたけど、その意味を見ていなかった。第二引数はv7.0では改行コードだったが、v8.0では削除され引数は1つになったようだ。

8-3 独自のサービスの定義

debug:containerでエラーとなった。

> php.exe C:\Users\ishida\PhpstormProjects\classic-symfony\bin\console debug:container app.inquiry_csv_builder


  [Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
  The file "C:\Users\ishida\PhpstormProjects\classic-symfony\src\AppBundle\De
  pendencyInjection/../Resources/config\services.yml" does not contain valid
  YAML.



  [Symfony\Component\Yaml\Exception\ParseException]
  The reserved indicator "@" cannot start a plain scalar; you need to quote t
  he scalar at line 7 (near "arguments: [%csv_encoding%, @app.inquiry_reposit
  ory]").

'@app.inquiry_repository'とシングルクォートで囲む必要があった。

8-4 独自の設定値の定義

この本の山場であり、Symfonyの最大の特徴ではないかと思う。

MemberjoinedDate@var \DateTimeとなっているがstringなのでは?

prototypeがわからない。

    members:
        山田: {part: トランペット, joinedDate: "2010-10-01"}
        田中: {part: バイオリン, joinedDate: "2008-04-10"}

同じようなものを繰り返す時に使うということか。

例えばこれを

    members:
        - {name: 山田, part: トランペット, joinedDate: "2010-10-01"}
        - {name: 田中, part: バイオリン, joinedDate: "2008-04-10"}

と書くこともできるのだろうか。

できた。

https://github.com/iakio/classic-symfony/commit/d9f4e70820c180996ec9b8704290f450e5893d73

でも一意な識別子がある場合は元の書き方の方が良さそうだ。