PHPMailer & PHP HTML to Text
php 內建的 mail() 是透過 local smtp, 但要走外面的 smtp server 的話, 可以用 PHPMailer 另外 HTML to Text 也有人家寫好的套件可以用 html2text
php 內建的 mail() 是透過 local smtp, 但要走外面的 smtp server 的話, 可以用 PHPMailer 另外 HTML to Text 也有人家寫好的套件可以用 html2text
新舊版本的寫法差蠻多的,被舊的 phalcon devtools 自動產生的 model 給陰了..
最近踩到 apcu 的 deadlock 地雷,紀錄一下
可以用 fs 或者 shelljs 來做,各有千秋 //using fs fs = require(‘fs’); console.log((fs.readdirSync(‘../json/’)).length); //using shelljs shell = require(‘shelljs’); console.log((shell.ls(‘../json/’)).length);
在傳統的 asp 可以用 include 的方式,但在 asp.net 還是寫在 global.asax 或者用實作 IHttpModule 的方式來處理
主要重點在 1) 產生 postdata array 2) 檢查 response http status code 3) curl_options
主要參考https://www.sitepoint.com/how-to-use-ssltls-with-node-js/ 依照順序是 先產生一個 RSA 2048 bit 的 key 產生一個 certification signing request 如果測試用可以加上第三步驟,把加密移除掉 最後做 self-sign,如果沒有用第三步驟地話要把 server.key 換為 server.enc.key $ openssl genrsa -des3 -out server.enc.key 2048 $ openssl req -new -key server.enc.key -out server.csr $ openssl rsa -in server.enc.key -out server.key $ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt 然後就可以拿去 node.js 用了 […]
在一般狀況下其實不需要自訂404 page也不會怎麼樣,但是如果用 phalcon dev tools 做 CRUD 頁面出來,有些狀況可能是不需要 create 資料的,比方說對 log 只需要看,沒有道理從頁面上手動 create
Sometimes you need a JSON RESTful api interface in a MVC controller, which usually generate HTML results to users. public function createAction() { $this->view->disable(); $resp = new \Phalcon\Http\Response(); $resp->setHeader(“Content-Type”, “application/json”); //….. $resp->send(); return; }
原本 php 要做 cache 就只能用 apc 這個 package (pecl install apc), 但從 php 5.6 之後,有了 opcache,可以取代掉一部分工作。詳細可以看這邊。 然而 opcache 只有做 code caching,所以 user data caching 的工作還是要找其他的方案,但是在我自己的環境(ubuntu 16.04, apache 2.4, php 7, phalcon 3) 已經不能安裝 apc(會出錯),所以只好用 apcu (pecl install apcu) 至於使用方式跟 apc 差不多,可以參考官方文件說明。我覺得最好的地方在於可以設 ttl timeout,這樣對於一些暫時性的資料(例如 authentication key)就不用開個 table 去維護了。另外如果資料不多,也不用去搞個 redis 來當 cache…