發表文章

目前顯示的是 12月, 2014的文章

Laravel Models 驗證套件: laravelbook/ardent

這套件是 Eloquent Model class 的擴充,可以讓你的 model 更加聰明達到自我驗證。 對於輸入資料的驗證有許多好用的 functionality, utilities and methods。 簡單來說可以帶來以下優點: 優點1: 將"驗證"從 controller 移到 model 符合 “fat models, skinny controllers” 原則。 這樣的 code 組織方式可提升專案的可讀性與維護性。 本篇也舉例,若是需求變動此時要 RESTful API for the mobile,用一般的方法會在 controller 複製出相同的程式碼,這也違反 DRY (Don’t Repeat Yourself) 原則, 較佳做法是在 model 建立 signup() 方法,同時用來處理 Web/Mobile ...等。 優點2:model auto-hydrate 表單資料自動混入,讓流程變得更簡潔。 $user = new User; $user->first_name = Input::get('first_name'); $user->last_name = Input::get('last_name'); $user->email = Input::get('email'); $user->password = Hash::make(Input::get('password')); $user->save(); 以下2行等同上述效果。 $user = new User; $user->save(); field 將會自動塞入 Input object data(當然表單的輸入欄為名稱要和DB field一樣才行) 優點3.同時也有更多的 Model Hooks 擴充原本的Model Events 像是 beforeSave() 方法 常用的情境有 1.用來處理 slug。 2.password 加密處理。 優點4.Defining Relationships (the

將 Server 端檔案同步於本機,並可使用 Sublime Text 進行編輯

圖片
習慣使用 Sublime Text 來開發的同學,會遇到檔案在 local 與 remote 同步的問題, 解法1:在 local 使用 SFTP 上傳到 remote (有點麻煩) 解法2:使用 mount 遠端目錄(目前我使用較佳方法) 1.在本機安裝 sshfs-fuse 以達到透過SSH(SFTP)去掛載遠端的檔案目錄     1.1下載安裝 OSXFUSE(2.7.3)         http://sourceforge.net/projects/osxfuse/files/osxfuse-2.7.3/osxfuse-2.7.3.dmg/download     1.2下載安裝 SSHFS(2.5.0)         https://github.com/osxfuse/sshfs/releases/download/osxfuse-sshfs-2.5.0/sshfs-2.5.0.pkg 2.mount 指令 sshfs bobochen@<主機路徑>:<遠端路徑> <本機路徑> -oauto_cache,reconnect,defer_permissions,negative_vncache,noappledouble,volname=ImMount 指令後方帶了一堆參數,主要是要解決網路斷線後不會自動重新連線的問題。 3.umount 指令 umount -f <本機路徑> 搭配 iTerm2 使用更輕鬆,將 mount,umount 完整指令進行設定。

關於網站開發團隊資訊的 humans.txt 檔案

圖片
相較於 robots.txt 檔案,關於網站開發團隊資訊的 humans.txt 相對少人知道, 好奇查了幾個網站: GitHub:把團隊成員名單列出,還附上他們各自的 GitHub https://github.com/humans.txt  而 Google 則是附上應徵的網址XD https://www.google.com.tw/humans.txt