Easy methods to code mining script utilizing PHP?

I can’t perceive the way to do mining utilizing code. Is it doable to make use of somebody’s API to connect with a pool and to simplify calculations for the script?
I am asking for any assist with this query.