PHPackages                             totten/pogo - 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. totten/pogo

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

totten/pogo
===========

Run PHP scripts with inline dependencies

v0.6.0(1y ago)4481MITPHPPHP &gt;=7.3.0

Since Dec 2Pushed 1y ago2 watchersCompare

[ Source](https://github.com/totten/pogo)[ Packagist](https://packagist.org/packages/totten/pogo)[ RSS](/packages/totten-pogo/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)Dependencies (5)Versions (14)Used By (0)

PHP On the Go (`pogo`)
======================

[](#php-on-the-go-pogo)

Pogo allows you to write small PHP scripts which use PHP libraries (courtesy of `composer`/`packagist`)... but it *doesn't* require you setup a special-purpose folder, project, or repository. To use a dependency, simply add a small pragma into your script. For example:

```
#!require symfony/yaml: ~4.4
```

This makes it easier to use PHP libraries for glue-scripts, throw-away scripts, quick experiments, etc.

Example
-------

[](#example)

Let's pick a small task that requires a few libraries -- suppose we want to generate a pretty PDF from a source-code file (`*.php`, `*.json`, etc). We'll need a pretty-printer ([scrivo/highlight.php](https://github.com/scrivo/highlight.php)) and a PDF generator ([dompdf/dompdf](https://github.com/dompdf/dompdf)).

Skimming the README for each library, one finds a few introductory snippets. I took these, added the `#!require` pragmas, and improvised a little on the `$html` variable. This becomes a small script, `code2pdf.php`:

```
