Posts

Showing posts with the label laravel

DOMPDF 內嵌圖片無法顯示的問題 pdf image background no show

Image
將測試站搬到正式站後(不同主機) 遇到由 dompdf 產生的 pdf 檔案內嵌圖片出不來的問題 圖片是用 img 跟 background 載入的 如果連結換成測試站的卻可以 比對兩邊 nginx 設定後才發現應該是 SSL 憑證的問題 測試站在 SSL Labs 拿到的是 A+ 等級 但正式站缺只有 B 後來修改 nginx 設定檔並將 ssl_certificate 設定正確的 .cer 檔案後 重啟 nginx 再次測試跑 SSL Labs 測試就拿到 A+ 喔 PS. 如果前後端分離的情狀下,主要修改的 API 站台,建議將所有站台一併更新至 A+

Lumen 10 CORS not working / Lumen 10 無法使用第三方 CORS 套件

由於 Laravel 9.2 後就內建 CORS 的關係 Lumen 10 之後的版本也沒有第三方套件支援 CORS 了 這邊主要是在說明該如何設定內建的 CORS 1. 新增 config/cors.php 檔案可以去複製 Laravel 10 的 cors.php 2. 修改 bootstrap/app.php,加入以下這段  $app->configure('cors'); $app->middleware([     \Illuminate\Http\Middleware\HandleCors::class, ]);

Lumen 5.5 TimeZone

Lumen 的 timezone 設定於 .env 有兩個參數就要設定 APP_TIMEZONE=Asia/Taipei DB_TIMEZONE=+08:00 如果只設定 APP_TIMEZONE 的話 部分寫入資料庫的資料會有問題

如何使用 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...

Laravel / Lumen Timezone

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