tkuchikiの日記

新ブログ https://blog.tkuchiki.net

Symfony

Symfony2で Twig 関数の aseet や path のURLを絶対URLにする方法

Controller内であれば、generateUrl の第3引数を true にすることで絶対パスにすることができるが、Twig関数で生成したパスを絶対URLにする方法は多少調査した感じでは見当たらなかった。symfony2 - How to get the full url for an asset in Controller? - …

Symfony2 で CSRF Validation を ON にした時のテストの書き方

CSRF Validation を 有効にしている時のテストの書き方を調べた。 stackoverflow でそれっぽいものを発見(testing - Get the CSRF token in test - Stack Overflow)。 $crawler = $client->request('GET', '/test'); $extract = $crawler->filter('input[nam…

Symfony2 で composer install|update 時に、「Class .... is not autoloadable, can not call post-update-cmd script 」が出た時の対処法

php composer.pher install|update で、 Class .... is not autoloadable, can not call post-update-cmd script が出たら、 vendor を消して入れなおせばいいそうです。 一々消すの面倒ですね。※参考 https://github.com/symfony/symfony-standard/issues/2…

Symfony2.1以降で、Twigにflash messageを表示させる際の書き方

Symfony2.3で、 Symfony\Component\HttpFoundation\Session\Session の、getFlashs, setFlashs, getFlash, setFlash, hasFlash, removeFlash, clearFlash が削除されます。 公式ドキュメントの、 http://symfony.com/doc/master/components/http_foundation/…

Symfony2で、「The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, but is an instance of class DateTime. ...」というエラーが出る場合について

Entityのカラムをdatetimeで設定した状態で、FormTypeに、 $form->add('created_at', 'text'); のように、'datetime'以外を設定すると、 The form's view data is expected to be of type scalar, array or an instance of \ArrayAccess, but is an instance…

KnpPaginatorBundleでInvalid parameter number: ... エラーが発生した場合の対処法

https://github.com/KnpLabs/KnpPaginatorBundle/issues/117こちらに対処法が書いておりました。 config(option) の distinct: true を falseに変更すれば動くようになります。 knp_paginator: page_range: 5 # default page range used in pagination contr…

Eclipse にPHPとSymfonyの環境を整える手順

PHPなど http://phpmentors.jp/post/27519578771/eclipse-php-5 を参考にしました Symfony plugin Eclipse Marketplace から、Symfony plugin と Twig plugin をインストール