Transcript
Page 1: Building a framework agnostic API

Building a framework agnostic API

David Manners@mannersd

Page 2: Building a framework agnostic API

How to un-Magento your Magento code/developers

David Manners@mannersd

Page 3: Building a framework agnostic API

Disclaimers

• Not for all,• Not perfect,• Will not code for you!• Love to build in blocks,

Page 4: Building a framework agnostic API

Are you sitting comfortably

Page 5: Building a framework agnostic API

Are you sitting comfortably

• Magento 1 EOL,• New customer,• Lots of integrations,• Migration possible,

Page 6: Building a framework agnostic API

ERP API Magento

Page 7: Building a framework agnostic API

How do you build this?

Page 8: Building a framework agnostic API

What on earth is a store?

Page 9: Building a framework agnostic API

Interface everything!

Page 10: Building a framework agnostic API

Interface everything

• Take your domain and enforce your properties,• Tell frameworks how to interact with your domain,

Page 11: Building a framework agnostic API

Domain Objects

Page 12: Building a framework agnostic API

A middleware

Page 13: Building a framework agnostic API

A middleware

• Pick one you like!• Take request,• Give response,• SIMPLES!

Page 14: Building a framework agnostic API

Response/Request parsing

Page 15: Building a framework agnostic API

Build a bridge

Page 16: Building a framework agnostic API

The results!

Page 17: Building a framework agnostic API

The results!

• Ready to go with M1,• Ready to switch to M2,• Happy Customer?• Happy Developers?

Page 18: Building a framework agnostic API

All that glitters is not gold

Page 19: Building a framework agnostic API

Build from the interfaces

Page 20: Building a framework agnostic API

Store Interface

interface StoreInterface{ public function getIdentifier(); public function getCode(); public function getName(); public function getActive();}

Page 21: Building a framework agnostic API

StoreRepositoryInterface

interface StoreRepositoryInterface{ public function find(array $ids = []); public function save(StoreInterface $store);}

Page 22: Building a framework agnostic API

ExporterInterface

interface ExporterInterface{ public function setIdentifier(array $identifier = []); public function execute();}

Page 23: Building a framework agnostic API

ImporterInterface

interface ImporterInterface{ public function execute();}

Page 24: Building a framework agnostic API

Bridge Interface

interface BridgeInterface{ public function getPageRepository();}

Page 25: Building a framework agnostic API

Build from the interfaces

• implement ExporterInterface• implement ImporterInterface• implement StoreInterface

Page 26: Building a framework agnostic API

Build from the interfaces (M1/M2)

• Implement BridgeInterface,• Implement StoreRepositoryInterface

Page 27: Building a framework agnostic API

Let Magento do Magento

Page 28: Building a framework agnostic API

Do one thing well

Page 29: Building a framework agnostic API

Free your developers

Page 30: Building a framework agnostic API

Enjoy coding again

Page 31: Building a framework agnostic API

Can I see it?

• https://github.com/sitewards/setup• https://github.com/sitewards/setup-mage2• https://github.com/sitewards/setup-mage1

Page 32: Building a framework agnostic API

Building a framework agnostic API

David Manners@mannersd


Top Related