Then all you need to do is include your .php file and instantiate the object.
include 'path/to/myclass.file.php';
$obj = new MyObject;
Of course, your snippet should check for the existence of the file and the object to catch any errors if for some reason the file can’t be included.
Consider the Jot snippet. The snippet code starts with
$jotPath = $modx->config['base_path'] . 'assets/snippets/jot/';
include_once($jotPath.'jot.class.inc.php');
$Jot = new CJot;
then the rest of the snippet’s code consists of setting up the object’s settings based on the parameters used in the Jot snippet tags before finally calling object’s main function, returning its output.
$Jot->VersionCheck("1.1.4");
$Jot->Set("path",$jotPath);
$Jot->Set("action", $action);
$Jot->Set("postdelay", $postdelay);
$Jot->Set("docid", $docid);
$Jot->Set("tagid", $tagid);
...
return $Jot->Run();