Create a extension for civicrm
You need to install civix to create civicrm extension and then follow documentation for creating module extension. There are many examples of extension under civicrm.org. The easiest one to start would be 


https://civicrm.org/extensions/api-key
https://civicrm.org/extensions/phone-number-validator
https://civicrm.org/extensions/show-contact-deceased
https://civicrm.org/extensions/sms-api
https://civicrm.org/extensions/extended-logging-report
https://civicrm.org/extensions/olark-chat
https://civicrm.org/extensions/birthdays-month
https://civicrm.org/extensions/show-member-ids
https://civicrm.org/extensions/mysms-mantra-sms-gateway-integration
https://civicrm.org/extensions/civicrm-country-manager


Ref: https://www.youtube.com/watch?v=lrk8X_jt0wU

HTH

Pradeep