travist / cliphp Goto Github PK
View Code? Open in Web Editor NEWAn easy to use CLI ( command line interface ) PHP class that allows for user input.
An easy to use CLI ( command line interface ) PHP class that allows for user input.
This is a simple to use Command Line Interface ( CLI ) PHP class that allows for user input. This script can take parameters to your script in 3 different ways... 1.) User Input - With this method, you can allow your script to ask the user for the parameters for your script. <?php require_once('cli.php'); // Create a new CLI object. $cli = new CLIPHP(); // Ask the user for their first name. $cli->get('first', "What is your first name?"); // Ask the user for their last name. $cli->get('last', "What is your last name?"); // Now print the results. print $cli->args['first']; print $cli->args['last']; ?> 2.) Cached User Input - With this method, you can cache the user results inside of a "config" file on the root path of where this script is ran. - Using this method, they will be asked for the parameters only once, and then every other time the script is ran, the cached results will populate the parameters. Like so... <?php require_once('cli.php'); // Create a new CLI object. $cli = new CLIPHP(); // Ask the user for their first name. PASS TRUE TO CACHE THE RESULT!!! $cli->get('first', "What is your first name?", TRUE); // Ask the user for their last name. PASS TRUE TO CACHE THE RESULT!!!! $cli->get('last', "What is your last name?", TRUE); // Now print the results. print $cli->args['first']; print $cli->args['last']; // Now create a separate CLI object. $cli2 = new CLIPHP(); // Print's the cached results from the first object. print $cli2->args['first']; print $cli2->args['last']; ?> 3.) Direct arguments... - With this, you can just pass the arguments directly using the "-param value" method. php mycli.php -name "Travis" -last "Tidwell" - Then inside of your script, you just need to provide the following.. - It will first check to see if values have been passed as arguments, and then if so, it will use those instead. <?php require_once('cli.php'); // Create a new CLI object. $cli = new CLIPHP(); // Ask the user for their first name. $cli->get('first', "What is your first name?"); // Ask the user for their last name. $cli->get('last', "What is your last name?"); // Now print the results. print $cli->args['first']; print $cli->args['last']; ?>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.