Posts

Showing posts from April, 2018

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 cache   - Installing i