Skip to main content

PHP CLI Development Intro - #89

Published: April 27, 2022 | DevDrawer

Estimated Reading Time
1 minutes
Video Duration
32:19 minutes

If you are not familiar with CLI, then this is the perfect introduction for you. In this tutorial, I will go over how to write command-line-driven PHP where you can hit an external API and parse results by simply typing a single command in your terminal. With CLI, you can give other non-developers a way to run your code with flags and variables that will be contained within 1 line in either CMD, Powershell, Terminal, or other command-line interfaces.

This tutorial is not in-depth by any means but should help you get started with exploring CLI and PHP development.

Code we will run in CLI:

php index.php {postID or NULL} {-c or NULL} {true or null|false}

00:00 Intro

00:45 What is CLI?

01:48 Setting Up Our Autoloader

06:45 Creating Our Data Class

13:53 Setting Up Arguments in CLI

16:35 Dumping Our Arguments

20:26 Hitting Our API

26:24 Dumping the API Data

Download tutorial files here:

⭐ If you would like to buy me a coffee because I created something that helped you, it would be much appreciated! :

⭐ Join this channel to get access to perks:

⭐ Become a Patreon to show support and get exclusive access to content: