wuppo / paperclip
PHP CLI
v1.4.0
2025-05-21 13:07 UTC
Requires
- google/analytics-data: ^0.22.2
- google/apiclient: ^2.18
- vlucas/phpdotenv: ^5.6
README
A PHP CLI tool to manage custom commands.
Setup
- Install the package via composer
- Run
composer install
to install the required packages - Create a PHP file that will be used for cli execution (for example
execute.php
) - Add the following code to the file:
#!/usr/bin/env php <?php use Paperclip\Enums\ColorOption; use Paperclip\Paperclip; # Composer autoload $autoload = __DIR__ . '/vendor/autoload.php'; if (file_exists($autoload)) { require $autoload; } # Paperclip setup Paperclip::instance() ->setup($argv) ->execute();
Customising Paperclip
You can also customise the look of Paperclip by adding a config array to the Paperclip::instance()->setup()
method.
# Paperclip setup Paperclip::instance() ->setup($argv, [ 'name' => 'Paperclip', 'display_subject' => false, 'colors' => [ 'banner' => [ 'row' => ColorOption::DARK_GRAY->value, 'braces' => ColorOption::LIGHT_RED->value, 'slashes' => ColorOption::LIGHT_RED->value, 'title' => ColorOption::WHITE->value, ], 'info' => [ 'title' => ColorOption::YELLOW->value, 'text' => ColorOption::LIGHT_GRAY->value, 'description' => ColorOption::WHITE->value, 'highlight' => ColorOption::GREEN->value, 'parameter' => ColorOption::WHITE->value, ], 'notes' => [ 'title' => ColorOption::MAGENTA->value, 'text' => ColorOption::WHITE->value, 'highlight' => ColorOption::LIGHT_YELLOW->value, 'bullet' => ColorOption::MAGENTA->value, ] ] ] ) ->execute();
(This example shows the default settings)
Creating commands
From the root of your project you can add Commands however you like. The default structure is classes/Commands/... (in composer: NAMESPACE/Commands/...)
Make the new command be a child of the Command.php
class and register this in the
paperclip.commands.json
file in the root of your project.
Example:
[
'NAMESPACE/Commands/ExampleCommand'
]
Composer packages
- "google/apiclient" - "vlucas/phpdotenv" - "google/analytics-data"
PHP Required Extensions
- "bcmath" - "calendar" - "Core" - "ctype" - "date" - "dom" - "exif" - "FFI" - "fileinfo" - "filter" - "ftp" - "gettext" - "hash" - "iconv" - "json" - "libxml" - "mbstring" - "openssl" - "pcntl" - "pcre" - "PDO" - "Phar" - "posix" - "random" - "readline" - "Reflection" - "session" - "shmop" - "SimpleXML" - "sockets" - "sodium" - "SPL" - "standard" - "sysvmsg" - "sysvsem" - "sysvshm" - "tokenizer" - "xml" - "xmlreader" - "xmlwriter" - "xsl" - "Zend OPcache" - "zlib"