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.

9748d71c4e18135a4f044d5b93af0ee3?s=128

wernerkrauss

October 12, 2019
Tweet

Transcript

  1. One Code To Run Them All 12.10.2019 www.silverstrip.es 1

  2. 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
  3. With SilverStripe 3 • Two repositories with each settings •

    One theme per installtion • Double work updating, testing 12.10.2019 www.silverstrip.es 3
  4. 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
  5. ENVIRONMENT • A server specific setting • A switch for

    configuration 12.10.2019 www.silverstrip.es 5
  6. 12.10.2019 www.silverstrip.es 6

  7. 12.10.2019 www.silverstrip.es 7

  8. 12.10.2019 www.silverstrip.es 8

  9. 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
  10. 12.10.2019 www.silverstrip.es 10

  11. 12.10.2019 www.silverstrip.es 11

  12. Different PHP Code • Some Extensions are only applied for

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

    Satisfy your customer 12.10.2019 www.silverstrip.es 13
  14. Thanks! www.silverstrip.es 12.10.2019 www.silverstrip.es 14