Monday, January 02, 2012

Doctrine2 ORM add query result cache and delete cache

// add query result cache
$query = $this->createQueryBuilder('i')
              ->where('i.delete = false')
              ->getQuery();
$query->useResultCache(true, 3600, 'allItems');
$items = $query->getArrayResult();

// delete cache
$em->getConfiguration()
   ->getResultCacheImpl()->delete('allItems');

Saturday, December 17, 2011

Develop Symfony2 with Eclipse

1. Download Eclipse IDE for Java EE Developers

2. Extract the archive file to where you want to install Eclipse.

3. Open Eclipse, Go to Help->Install New Software...

4. Add Symfony-2-Eclipse-Plugin repository: http://pulse00.github.com/Symfony-2-Eclipse-Plugin/

5. Install All of them. (PDT Extensions, PHP Development Tools, Symfony, YEdit)

6. Add Eclipse Color Theme plugins repository: http://eclipse-color-theme.github.com/update

7. Install Eclipse Color Theme

8. Download Eclipse Symfony2 theme

9. Go to Window->Preferences->General->Appearance->Color Theme , and install the Symfony2 theme.

10. ALL DONE! ENJOY Symfony2!

ex1. Go to PHP->Code Style->Formatter(PDT Tooles) Change Active profile to "Symfony [built in]"

ex2. Edit theme color in Twig: Normal, String

ex3. Edit theme color in YEdit: Scalars, Documents, Default

Wednesday, December 07, 2011

Tuesday, November 08, 2011

Javascript and PHP AES encrypt decrypt library

This is a Javascript AES encrypt decrypt library
AES Advanced Encryption Standard

And this is a PHP AES encrypt decrypt library
AES in PHP

Friday, November 04, 2011

Symfony theme for NetBeans

A nice guy make a symfony color theme for NetBeans. You can download from his googlecode page: Symfony Color Scheme for NetBeans v1.3

解決 DejaVu Sans Mono 字型在 NetBeans 下中文顯示成方塊的問題

  1. 找到 NetBeans 安裝路徑, ex: C:\Program Files\NetBeans 7.0.1
    進入 etc 資料夾 ex: C:\Program Files\NetBeans 7.0.1\etc
    打開 netbeans.conf 並搜尋 netbeans_jdkhome 參數
    該參數存放的是 JRE 的路徑 ex:"C:\Program Files\Java\jre6"
  2. 進入 JER 的路徑, 並進到 lib 資料夾 ex: C:\Program Files\Java\jre6\lib
  3. 複製一份 fontconfig.properties.src 並更改檔名成 fontconfig.properties
  4. 編輯 fontconfig.properties 檔
    新增下列的內容
    filename.DejaVu_Sans_Mono=DejaVuSansMono.ttf
    filename.DejaVu_Sans_Mono_Bold=DejaVuSansMono-Bold.ttf
    filename.DejaVu_Sans_Mono_Bold_Oblique=DejaVuSansMono-BoldOblique.ttf
    filename.DejaVu_Sans_Mono_Oblique=DejaVuSansMono-Oblique.ttf
    
    修改下列的內容
    sansserif.plain.alphabetic=DejaVu Sans
    sansserif.bold.alphabetic=DejaVu Sans Bold
    sansserif.italic.alphabetic=DejaVu Sans Oblique
    sansserif.bolditalic.alphabetic=DejaVu Sans Bold Oblique
    monospaced.plain.alphabetic=DejaVu Sans Mono
    monospaced.bold.alphabetic=DejaVu Sans Mono Bold
    monospaced.italic.alphabetic=DejaVu Sans Mono Oblique
    monospaced.bolditalic.alphabetic=DejaVu Sans Mono Bold Oblique
    sequence.sansserif.x-windows-950=
      alphabetic,chinese-ms950,dingbats,symbol,chinese-ms950-extb
    sequence.monospaced.x-windows-950=
      alphabetic,chinese-ms950,dingbats,symbol,chinese-ms950-extb
        
  5. 做完上述的修改後, 再進入 NetBeans -> Tools -> Options -> Fonts & Colors -> Syntax -> Default -> Font, 選擇 Monospaced 字型, 這樣就可以正確地顯示 DejaVu Mono 的字型了, 收工!