This is a 5-minute package I threw togehter that simply wraps the Mac, Windows, and (most common) Linux commands for copying contents to the clipboard. I don't handle reading files. You'll have to do that yourself. I simply pipe whatever contents you provide to the appropriate command based on the operating system reported by php_uname().
composer require edgrosvenor/php-clipboard
<?php
use Edgrosvenor\PHPClipboard\Clipboard;
class CopyStuff
{
public function copyMyName($name = 'Ed Grosvenor')
{
$clipboard = new Clipboard();
$clipboard->copy($name);
// 'Ed Grosvenor' has been copied to your clipboard
}
}