Command-line client of Cloudflare API written in PHP. Allows to:
- Execute Cloudflare API commands, like listing available
zones
or changingzones:settings:development_mode
- Parse documentation
- Generate commands from parsed information (Not completed yet)
Download the latest binary
wget https://raw.githubusercontent.com/miamibc/cloudflare-cli/main/builds/cloudflare-cli
To work with Cloudflare from cloudflare-cli
, you need to create an API token with all necessary permissions and pass it as env variable.
You have at least two ways do it (change xxxxxx to your API token):
-
Create
.env
file withCLOUDFLARE_API_TOKEN
variable setecho 'CLOUDFLARE_API_TOKEN="xxxxxx"' > .env
-
Or export as a Bash variable
export CLOUDFLARE_API_TOKEN="xxxxxx"
Now you can check, is it set properly, by running
php cloudflare-cli user:tokens:verify
If you did setup correctly, you will see id
and status
of your API token.
Additionnaly, you can make cloudflare-cli executable and visible system-wide
chmod a+x cloudflare-cli
sudo ln -s $(pwd)/cloudflare-cli /usr/bin/
Now you can run it as a simple command, from any directory
cloudflare-cli
To get list of all commands available, run cloudflare-cli without arguments
cloudflare-cli
To get more information on command, add help
and command
you need to get help for, for example
cloudflare-cli help zones:settings:development_mode
Project is made with help of Laravel Zero framework.
Clone the project source code
git clone https://github.com/miamibc/cloudflare-cli.git
Go to the created directory
cd cloudflare-cli
Install composer dependencies
composer install
Create new command
php cloudflare-cli make:command
And add functionality to the new file in app/Commands
directory.
You can add App\Cloudflare\Client $client
as a parameter of handle()
method, to inject very simple and useful Cloudflare client, that performs authorization, results pagination and possibility to parse documentation.
To test components, run phpunit
php vendor/bin/phpunit
To create phar file, use this command and answer few questions
php cloudflare-cli app:build
Built binary (PHAR) file can be found in builds
folder.
Do you like this project? Support it by donating by PayPal Donate
Cloudflare-cli is an open-source software licensed under the MIT license.