Posts

InvalidArgumentException: Field is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 580 of /core/lib/Drupal/Core/Entity/ContentEntityBase.php)

從 Drupal 8.4.2 升級到 8.5.2 這次升級主要是資安的問題 遇到了以下的錯誤訊息(英文) 「The website encountered an unexpected error. Please try again later.」 中文則是 「網站遇到非預期錯誤。請稍後再試。」 以上的錯誤訊息算是非常常見的 有看沒有懂 基本上把該更新的檔案都有丟上去後 會出錯大概就是以下幾個問題: 資料庫沒升級 套件版本相衝突 資料夾權限沒設定好 升級 drupal 不一定每次都要執行資料庫升級 不過遇到問題的時候就跑一下 /update.php 如果這邊畫面可以正常顯示 那就跑一下資料庫升級 如果跑完升級後還是有錯 那就到 /devel/reinstall 那邊看看還有什麼錯誤訊息(需要裝 devel 模組) 因為一般頁面通常都進不去 所以要從特別的頁面進去才能知道發生什麼事

如何使用 Lumen 寄信 Lumen Mail example

由於 Lumen 沒有內建 Mail function 網路上找到整合 Mail 的方式大概有下面兩種 我實作的是第一種 第二種主要是把 Lumen 被拔掉的功能給加回來 因為不需要其他的功能 這邊的環境是 Lumen 5.5.2 1. 需要先安裝 illuminate/mail 套件 不過不能只安裝 illuminate/mail 會出錯,要把相依的套件一起裝起 這部分別篇文章有介紹不贅述, 請參考這邊 2. 然後在 bootstrap/app.php 裡面加入這段 $app->register(\Illuminate\Mail\MailServiceProvider::class); 然後把這行前面註解移除 $app->withFacades(); 3. 安裝這個套件 phanan's cascading config composer require phanan/cascading-config: "~2.0" 把下面這兩行加入 bootstrap/app.php 裡面 $app->register(PhanAn\CascadingConfig\CascadingConfigServiceProvider::class); $app->configure('mail'); 4. 在 config 資料夾中新增一個 mail.php 檔案 將下方的程式複製到 mail.php 中 return array(   "driver" => "smtp",   "host" => "smtp.gmail.com",   "port" => 465,   "from" => array(       "address" => "account@gmail.com",       "name" => "Mailbox Name"   ),   "username" =...

Lumen 5.5 Mailer

Lumen 沒有內建 Mailer 的功能 Note: By default, the illuminate/mail package is not included with Lumen, so you will need to add the illuminate/mail dependency in your composer.json file. 似乎沒什麼選擇 只有從 Laravel 移植過來的 illuminate/mail 如果直接使用 composer require illuminate/mail 會出錯 因為有太多版本了 建議還是從 composer.json 下手 將 "illuminate/mail": "^5.5" 加入 不過這時候執行 composer update 還是會出錯 root@kitchen maan_cs]# composer update Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 7 installs, 0 updates, 0 removals   - Installing symfony/css-selector (v4.0.8): Loading from cache   - Installing tijsverkoyen/css-to-inline-styles (2.2.1): Loading from cache   - Installing doctrine/lexer (v1.0.1): Loading from cache   - Installing egulias/email-validator (2.1.4): Loading from cache   - Installing swiftmailer/swiftmailer (v6.0.2): Loading from cache   - Installing erusev/parsedown (1.7.1): Loading from cac...

CentOS7 上安裝 SQL Server

Image
原來 Microsoft 早在 2016 年就讓 SQL Server 搬上了 Linux 了! 這真是個可喜可賀的好消息啊! 加入來源 $ sudo curl -o /etc/yum.repos.d/mssql-server.repo https://packages.microsoft.com/config/rhel/7/mssql-server-2017.repo 安裝 SQL Server $ sudo yum install -y mssql-server 設定 SQL Server 的版本及密碼 $ sudo /opt/mssql/bin/mssql-conf setup  選擇版本的時候會出現下面選項,如果用量不大的話可選擇免費的 Express  設定防火牆 $ firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="你的ip" port protocol="tcp" port="1433" accept' $ firewall-cmd --reload 參考來源: https://docs.microsoft.com/zh-tw/sql/linux/quickstart-install-connect-red-hat How to open port for a specific IP address with firewall-cmd on CentOS? [duplicate]

Laravel / Lumen Timezone

Lumen 跟 Laravel 的 Timezone 設定 都在 .env 裡面 預設是 UTC APP_TIMEZONE=UTC 可以改成所在地的 TZ 如 Asia/Taipei APP_TIMEZONE=Asia/Taipei

Howto use Postman test Cors

Image
Postman 是一個很方便測試 api 的工具 沒有他我不知道人生要怎麼過啊! 開發程式上由於不同主機都一定會遇到 Cors 的問題 如果不要自己寫程式測試 那最快的方式就是用 Postman 了 請記得這邊要選「options」 然後 Header 裡面加入這兩行就可以了 這邊的變數視你的狀況而定 我的環境是利用 token 帶 jwt token 且沒有使用認證的機制 Access-Control-Request-Headers : token Access-Control-Request-Method : GET Status 回傳 200 代表有開通 Cors 如果沒開通會回傳 405 我這邊 Server side 是用 Lumen 搭配 這個套件 使用

Google maps 空白或是 Google 圖片找不到

Image
這個問題我遇到了兩次 應該說是兩台電腦 之前公司的電腦發生這個問題 我以為是中毒 但掃毒也都沒有掃到 後來在另外一台電腦也遇到了一樣的問題 這兩台電腦一台是 Windows 一台是 Mac 後來在網路上找到了解答 但我不知道新版的 Chrome 要怎麼刪除單一 cookie 今天總算找到了 Settings -> Advanced -> Content settings -> Cookies 進去點選「See all cookies and site data」 然後在右上角角會出現 search cookies 輸入 www.google.com.tw 或是 www.google.com 就會出現下面的畫面 把 gsScrollPos-* 刪除即可(我的有 2x ~ 3x 個) 全部刪掉即可! PS. 不同語系國家會存在不同的網域 參考資料 Google Maps is not showing the map in Chrome