到目前為止,Laravel 是 PHP 開發人員構建 api 和 web 應用程序的首選。如果你是新手的話,將 Laravel 應用程序部署到線上服務器上可能有點棘手。
在本指南中,我們將向您展示在 Ubuntu 系統中部署 Laravel 應用程序的全過程。
必備條件
A server running Ubuntu (24.04 or 22.04 is recommended).
SSH
我本人使用的是 Windows 操作系統,涉及到的軟件安裝也是在 Windows 操作系統上。
感覺 Windows 使用 WSL 安裝 Linux 虛擬機,然後搭建開發環境,挺好用。
使用 WSL 在 Windows 上安裝 Linux
在 https://github.com/laravel/homestead 下載壓縮包。
這裏是為了使用 homestead/bin/wsl-init 腳本。
laravel 中實現註解注入
創建註解類
?php
declare(strict_types=1);
namespace App\Support\Attributes;
#[\Attribute(\Attribute::TARGET_PROPERTY)]
readonly class Injection
{
public function __construct(