title: PHP: Best Design For A Modular Payment System?
body: <p>What is the best way, using PHP, to design a modular system that can be added to as easily as possible? For example, if you had a shopping cart, you might have a payment base class that has all your required methods. Then you can have a Paypal class that extends that class, and a Visa/Mastercard that also extends the base class, but how do you actually put them in use?</p>
  
  <p>If you did a functional version of the cart, you could make a function called <code>doExecute</code> and pass in the required information. Then you name all the files as <code>Payment_Method.php</code>. The file names are then read, creating a list of acceptable payment methods. Once one is picked, that file is the only one included in the script, and then the <code>doExecute</code> method is called guaranteeing that the method in the payment method include file is the one called.</p>
  
  <p>However, for an object oriented approach, that really does work that well. How do you add in the additional methods without having to keep modifying the code to include objects of the new classes?</p>