Download - Building a framework agnostic API
Building a framework agnostic API
David Manners@mannersd
How to un-Magento your Magento code/developers
David Manners@mannersd
Disclaimers
• Not for all,• Not perfect,• Will not code for you!• Love to build in blocks,
Are you sitting comfortably
Are you sitting comfortably
• Magento 1 EOL,• New customer,• Lots of integrations,• Migration possible,
ERP API Magento
How do you build this?
What on earth is a store?
Interface everything!
Interface everything
• Take your domain and enforce your properties,• Tell frameworks how to interact with your domain,
Domain Objects
A middleware
A middleware
• Pick one you like!• Take request,• Give response,• SIMPLES!
Response/Request parsing
Build a bridge
The results!
The results!
• Ready to go with M1,• Ready to switch to M2,• Happy Customer?• Happy Developers?
All that glitters is not gold
Build from the interfaces
Store Interface
interface StoreInterface{ public function getIdentifier(); public function getCode(); public function getName(); public function getActive();}
StoreRepositoryInterface
interface StoreRepositoryInterface{ public function find(array $ids = []); public function save(StoreInterface $store);}
ExporterInterface
interface ExporterInterface{ public function setIdentifier(array $identifier = []); public function execute();}
ImporterInterface
interface ImporterInterface{ public function execute();}
Bridge Interface
interface BridgeInterface{ public function getPageRepository();}
Build from the interfaces
• implement ExporterInterface• implement ImporterInterface• implement StoreInterface
Build from the interfaces (M1/M2)
• Implement BridgeInterface,• Implement StoreRepositoryInterface
Let Magento do Magento
Do one thing well
Free your developers
Enjoy coding again
Can I see it?
• https://github.com/sitewards/setup• https://github.com/sitewards/setup-mage2• https://github.com/sitewards/setup-mage1
Building a framework agnostic API
David Manners@mannersd