PHPackages                             dlindberg/pasteboard - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dlindberg/pasteboard

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dlindberg/pasteboard
====================

Very basic MacOS pasteboard interface

1.0.3(8y ago)015MITPHPPHP ~5.6|~7.0

Since Feb 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/dlindberg/pasteboard)[ Packagist](https://packagist.org/packages/dlindberg/pasteboard)[ Docs](https://github.com/dlindberg/Pasteboard)[ RSS](/packages/dlindberg-pasteboard/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (5)Used By (0)

Pasteboard
==========

[](#pasteboard)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dfc6c2abe634a41b01c0d8f21200e44afe442ae7266707bd914599a1aabefe98/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646c696e64626572672f7061737465626f6172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dlindberg/pasteboard)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/091a8204f8e9204413d9e9ef611a70781944ec4c6c1b4cc881db7114fd62c64d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f646c696e64626572672f7061737465626f6172642f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/dlindberg/pasteboard)[![Coverage Status](https://camo.githubusercontent.com/14383317e16af46f25284a93dcd8883e7b2c3ef0296c02c7a57a34554d7bf57e/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f646c696e64626572672f7061737465626f6172642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/dlindberg/pasteboard/code-structure)[![Quality Score](https://camo.githubusercontent.com/0562070bae378f894519484149979edab6343a174a4827a1943504863bab3a35/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f646c696e64626572672f7061737465626f6172642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/dlindberg/pasteboard)[![Code Intelligence Status](https://camo.githubusercontent.com/91d3a76b77de01a61177eba6fba85d52bd907b82f2be46dfe1294594d2f7e737/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f646c696e64626572672f7061737465626f6172642f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)[![Total Downloads](https://camo.githubusercontent.com/18cf0504f6413ac0ec96b2a065986fd0c948c9b01f1c3d1b3a00b7c15d503989/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646c696e64626572672f7061737465626f6172642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dlindberg/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](https://github.com/thephpleague/skeleton) repository for component boilerplate.

Install
-------

[](#install)

Via Composer

```
$ composer require Dlindberg/Pasteboard
```

Usage
-----

[](#usage)

Pasteboard has three methods:

### Get

[](#get)

Retrieves a value from the clipboard.

```
Pasteboard::get();
```

***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

[](#set)

Copies a value to the clipboard.

```
Pasteboard::set(string $value);
```

***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

[](#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.

```
Pasteboard::setArray(array $values, array $options)
```

***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` when `true` the original contents of the clipboard will be restored at the end of execution. **Default:** `false`.
    - `wait` amount of time in seconds to wait between `set()` operations. **Default** `1`.
    - `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, the `wait` parameter is ignored when a `hearbeat` 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 of `set()`.

***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
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Dane Lindberg](https://github.com/dlindberg)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

3008d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/145a7517b65de71107e43e44c0dc0d7c1e8734b913fa931aaf9986f12e8f2ba1?d=identicon)[dlindberg](/maintainers/dlindberg)

---

Top Contributors

[![dlindberg](https://avatars.githubusercontent.com/u/684461?v=4)](https://github.com/dlindberg "dlindberg (29 commits)")

---

Tags

DlindbergPasteboard

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/dlindberg-pasteboard/health.svg)

```
[![Health](https://phpackages.com/badges/dlindberg-pasteboard/health.svg)](https://phpackages.com/packages/dlindberg-pasteboard)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
