Download the PHP package dlindberg/pasteboard without Composer
On this page you can find all versions of the php package dlindberg/pasteboard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dlindberg/pasteboard
More information about dlindberg/pasteboard
Files in dlindberg/pasteboard
Package pasteboard
Short Description Very basic MacOS pasteboard interface
License MIT
Homepage https://github.com/dlindberg/Pasteboard
Informations about the package pasteboard
Pasteboard
This is a very simple static utility class that gives access to the pbcopy
and pbpaste
interface on MacOS and other systems that support those shell commands. This utility is primarily useful in developing PHP command line tools. It endeavors to comply fully with PRS-1, PRS-2, and PRS-4.
This project also uses the thephpleague/skeleton repository for component boilerplate.
Install
Via Composer
Usage
Pasteboard has three methods:
Get
Retrieves a value from the clipboard.
Parameters: None.
Returns: The contents of the host computers clipboard or false
if the clipboard is empty or fails to return a value.
Note: no filters or santization is applied to the return value and it is prudent to treat the value as unsafe user input for the purposes of your application.
Set
Copies a value to the clipboard.
Parameters $value
any value that the pasteboard on the host computer accepts. The function does not validate that the value is safe or valid before attempting to pass it to the host computer. If you are sending user input, or the results of an http request to the computer's clipboard it is prudent ensure that whatever is sent to the clipboard is safe for the context you intend to paste it to.
Returns: true
on success or false
on failure.
Set Array
Sends an array of values one at a time to the clipboard pausing between each send. The function also has some advanced options defined in the $options array.
Parameters
$values
an array of values you wish to send to the host computer. The same notes as in set apply to each value.$options
an optional settings array. Available options:reset
whentrue
the original contents of the clipboard will be restored at the end of execution. Default:false
.wait
amount of time in seconds to wait betweenset()
operations. Default1
.depth
Specified recursion depth. Default:0
, nested arrays will be skipped.heartbeat
a user defined closure function that will execute each time the clipboard is set. This function overrides the default$hearbeat
function. Therefore, thewait
parameter is ignored when ahearbeat
is passed. The function should return a truthy value if execution should continue and a falsy value to terminate execution. Heartbeat is passed the result ofset()
.
Returns: true
on success or false
on failure.
Note: Without an advanced clipboard manager on the host machine, or passing a heartbeat function sending more than two to three items to clipboard will rapidly become untenable.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
Contributing
Please see CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Dane Lindberg
- All Contributors
License
The MIT License (MIT). Please see License File for more information.