How can the SOLID principles and Dependency Injection be applied to improve the structure and maintainability of PHP projects?

Issue: The SOLID principles and Dependency Injection can be applied to improve the structure and maintainability of PHP projects by promoting single responsibility, open-closed principle, Liskov substitution principle, interface segregation, and dependency inversion. Dependency Injection helps in decoupling classes, making them easier to test and maintain. PHP Code Snippet:

// Interface segregation principle
interface PaymentGateway {
    public function processPayment($amount);
}

class PayPalGateway implements PaymentGateway {
    public function processPayment($amount) {
        // Process payment using PayPal API
    }
}

class StripeGateway implements PaymentGateway {
    public function processPayment($amount) {
        // Process payment using Stripe API
    }
}

// Dependency Injection
class Order {
    private $paymentGateway;

    public function __construct(PaymentGateway $paymentGateway) {
        $this->paymentGateway = $paymentGateway;
    }

    public function checkout($amount) {
        $this->paymentGateway->processPayment($amount);
    }
}

// Implementation
$paypalGateway = new PayPalGateway();
$order = new Order($paypalGateway);
$order->checkout(100);