Upgrade to Pro — share decks privately, control downloads, hide ads and more …

One Code To Run Them All

One Code To Run Them All

Lightning talk at StripeCon EU 2019. How I managed to use one repository for two slightly different Silverstripe CMS installations.

wernerkrauss

October 12, 2019
Tweet

More Decks by wernerkrauss

Other Decks in Programming

Transcript

  1. The use case: Primo Products • Two online shops for

    New Zealand and Australia – https://primopromo.com.au/ – https://www.primoproducts.co.nz/ • 99% same code • One installation needs other extensions • Some different configurations (currency) • Same design, some minor differences (address in footer…) 12.10.2019 www.silverstrip.es 2
  2. With SilverStripe 3 • Two repositories with each settings •

    One theme per installtion • Double work updating, testing 12.10.2019 www.silverstrip.es 3
  3. With Silverstripe CMS 4 • More flexibility • One code

    base for both installations • Switch between shops via ENVIRONMENT variable • Sub-themes for shop specific tweaks 12.10.2019 www.silverstrip.es 4
  4. ENVIRONMENT • A server specific setting • A switch for

    configuration 12.10.2019 www.silverstrip.es 5
  5. Sub-Themes • SilverStripe cascades through a set of themes •

    The first valid file is returned • Only modify the files you need to change • Works for all files via URLResourceLoader • Templates, images, CSS, JS … 12.10.2019 www.silverstrip.es 9
  6. Different PHP Code • Some Extensions are only applied for

    a specific shop • Some methods check the ENVIRONMENT 12.10.2019 www.silverstrip.es 12
  7. Conclusion • Combine different tools • Simplify your project •

    Satisfy your customer 12.10.2019 www.silverstrip.es 13