implement a droplet into drupal and where

i had this .php see below code as a droplet that worked fine

but now in drupal 8.3.7 i don’t know where to ad it on.

could somebody help.

//:Create a random oneliner on your page
//:Use: [[OneLiner]]. The file with the oneliner data is located in /modules/droplets/example/oneliners.txt
$line = file (dirname(__FILE__)."/example/oneliners.txt");
shuffle($line);
return $line[0]; 

i.e.
onliner.txt
A bug in the code is worth two in the documentation.
According to my calculations the problem doesn’t exist.
A computer’s attention span is as long as its power cord.
A computer scientist is someone who fixes things that aren’t broken.

thanks for help

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed