PHP Classes

PHP Command Line Parser: Invoke functions to process command-line arguments

Recommend this page to a friend!
  Info   View files Example   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 62 All time: 10,446 This week: 73Up
Version License PHP version Categories
clp 1.0Free For Educatio...7Console, PHP 7


This package can invoke functions to process command-line arguments.

It can take as a parameter the $argv array passed to PHP as the array of command line arguments and an array that defines options on how to process those arguments.

The package can process the arguments by invoking a callback function that applications pass to process the command line argument values.

It can also call a given callback function to process when all arguments are processed and when no arguments are passed to the package.

Innovation Award
PHP Programming Innovation award nominee
April 2023
Number 11
PHP can start running scripts from the command line console shell using the PHP CLI version.

Those scripts may take arguments passed by the users in front of the PHP script name.

PHP can create an array of arguments to make it easier for the scripts to process the parameters.

This package simplifies the processing of arguments by providing a means to call given functions to help developers process each type of argument separately.

Manuel Lemos
Picture of Mat Jung
  Performance   Level  
Name: Mat Jung <contact>
Classes: 4 packages by
Country: Switzerland Switzerland
Age: 48
All time rank: 389431 in Switzerland Switzerland
Week rank: 284 Up6 in Switzerland Switzerland Up
Innovation award
Innovation award
Nominee: 2x


/* License: OSL-3.0
   To be launched in shell environment
   php Example1.php

require 'vendor/autoload.php';

$options = [
"actions" => [
"h|help" => "displayHelp",
"hello" => "callHello"
"flags" => [
"values" => [
"hello" => "world"
"events" => [
"onAfterProcess" => "parsingCommandLineFinished",
"onNoOptions" => "displayHelp"

$hello = new clp($argv,$options);

displayHelp() {
"$argv[0] hello=\"your_name\" | --h | -help | verbose | debug\n";

parsingCommandLineFinished($config) {
"Finished parsing command line.\n";

callHello($config,$method) {
"Hello {$config["values"]["hello"]}\n";
"Implemented by $method\n";

  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file composer.lock Data Auxiliary data
Accessible without login Plain text file Example1.php Example Example script
Plain text file Example2.php Class Class source
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Read me

  Files folder image Files  /  src  
File Role Description
  Plain text file clp.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:10,446
This week:73Up