前幾天 Laravel 推出 v10,另外舊版也不再提供安全更新。現況是:
- Laravel 10:支援到 2024 年 9 月
- Laravel 9 LTS:支援到 2024 年 9 月
- 其他版本均不再提供功能、安全修正
若專案需要 migration 到新版本的 Laravel,可以考慮使用 Laravel Shift 服務。
另外還有個要注意的:
- Laravel 9 可支援 PHP >= 8.0
- Laravel 10 僅支援 PHP >= 8.1,不再支援 8.0
軟體開發和生活瑣事
使用 symfony/polyfill-intl-idn 後發現有趣的事,不用特別去檢查 PHP extension 的 function 是否存在,只要 require symfony polyfill 以後,完全不需要進行任何設定就可以正常運作。
後來在 composer.json 看到 autoload 的寫法:
{
"autoload": {
"psr-4": { "Symfony\\Polyfill\\Intl\\Idn\\": "" },
"files": [ "bootstrap.php" ]
},
}
以前以為 autoload 只能挑其中一種方法使用,沒想到可以指定多種方法同時使用。
上面的設定方式,namespace 會在 class 使用時才 require 進來,而 bootstrap.php 則是在一開始就 require 並執行,polyfill 就在當下偵測並處理掉 extension functions。所以使用者 composer require 以後程式並不需要做任何修改。
假設有個 class:
class Woker
{
protected Queue $queue;
public function run()
{
while (!$this->queue->isEmpty()) {
$job = $this->queue->pop();
// do something
}
}
}
用 PHPUnit 建立 stub 以後,必須使用 reflection 來自訂 $queue property:
$worker = $this->getMockBuilder(Worker::class)
->disableOriginalConstructor()
->getMock();
$queue = $this->createMock(Queue::class);
$queue->expected($this->atLeast(1))
->method('isEmpty')
->willReturn(true);
// PHP Reflection on $worker
$refProperty = new \ReflectionProperty($worker, 'queue');
$refProperty->setAccessible(true);
$refProperty->setValue($crawler, $queue);
這樣寫 test case 蠻髒的,有點想要換 test framework ….
這份整理拖太久了,到 PHP 8.2 都上線了還沒寫完,所以就整理到 7.x 結束吧。
PHP 從約 5.2 版就開始慢慢的加上一些重大的改變,像是 PHP v5.3 開始支援 `namespace` 之後,開始有了 composer 各種套件系統的發展。這些改變讓 PHP 的開發和維護更方便、更簡單。以下記錄各版本重要的功能,以便在更新程式時可以更快的了解有什麼需要留意的事項。
備註:我沒用過 PHP 4.x,如果你還在用的話,請多保重 ….
新版本的 phpMyAdmin 預設會將資料表過多的清單分頁,以便加快頁面載入速度,但其資料表 filter / searching 只會針對當下的分頁進行搜尋,塑資料表在第二頁或後面的分頁,則會搜尋不到資料。
若希望 phpMyAdmin 在資料表清單中不要分頁,可以在 config.inc.php 設定檔最後新增參數:
$cfg['MaxTableList'] = 1000;