Windows support is here! 🔥 Read the full announcement →
NativePHP
⚠️ NativePHP is currently in alpha. We do not recommend distributing production releases of your applications yet.
Clipboard

#
Working with the Clipboard

NativePHP allows you to easily read from and write to the system clipboard using just PHP, thanks to the Clipboard facade.

#
Reading from the Clipboard

You can read text, html or image data from the clipboard using the appropriate method:

1use Native\Laravel\Facades\Clipboard;
2 
3Clipboard::text();
4Clipboard::html();
5Clipboard::image();

#
Writing to the Clipboard

You can write text, html or image data to the clipboard using the appropriate method:

1use Native\Laravel\Facades\Clipboard;
2 
3Clipboard::text('Some copied text');
4Clipboard::html('<div>Some copied HTML</div>');
5Clipboard::image('path/to/image.png');

Note that the image() method expects a path to an image, not the image data itself. NativePHP will take care of serializing the image data for you.

#
Clearing the Clipboard

You may also programmatically clear the clipboard using the clear() method.

1use Native\Laravel\Facades\Clipboard;
2 
3Clipboard::clear();

This is useful if you need the contents of the clipboard to expire after a certain amount of time.