The CLI SAPI according to php.net As of version 4.3.0, PHP supports a new SAPI type (Server Applica^on Programming Interface) named CLI which means Command Line Interface. As the name implies, this SAPI type main focus is on developing shell (or desktop as well) applica^ons with PHP
The CLI SAPI according to php.netPHP script execu^on via the command line interface
When to use• In crons• For batch tasks• For worker processes• Daemons• Process control• Interac^on with other binaries
Comparing the Apache & CLI SAPI Web based SAPI’s• HTTP is a stateless protocol• Request/response based• Limited interac^on• Sessions & cookies as workaround• Execu^on ^meouts• Limited request/response size
Comparing the Apache & CLI SAPI CLI SAPI• Controlable state• Controlable script execu^on• Con^nuous interac^on• No need for sessions• No execu^on ^meouts
Readline<?php$name = readline("Whats your name: ");$location = readline("Where do you live: ");echo PHP_EOL."Hello $name from $locationn";$ php readline.php Whats your name: ThijsWhere do you live: BelgiumHello Thijs from Belgium$
SignalsA signal is a limited form of inter-‐process communica^on used in Unix, Unix-‐like, and other POSIX-‐compliant opera^ng systems. Essen^ally it is an asynchronous no^ﬁca^on sent to a process in order to no^fy it of an event that occurred.