How to make extension to perform custom initialization on a Magento 2 start

- Magento 2

Magento 2 Development

There are at least two use cases in this situation. In Magento 2 you can custom mini-libraries with such short popular global functions as rm_customer_logged_in():

'

Unfortunately, such approach does not work for console apps. Therefore, for applications like setup:upgrade, use event handlers:

Source

More tips from The Magento 2 Developer’s Cookbook

'