Skip to content

A helpful tool for your CLI php project, pack to phar, init new project with quality tools etc.

Notifications You must be signed in to change notification settings

crazywhalecc/php-cli-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP CLI Helper

A simple PHP CLI helper.

Basic Usage

You can just download the packed executable phar for this helper.

wget https://github.com/crazywhalecc/php-cli-helper/releases/download/0.1.0/cli-helper
chmod +x cli-helper
# Run it!
./cli-helper

Pack Project to Single Executable File (PHP Installed required)

  1. move cli-helper into PATH
# If you don't want to move it, remember your download path and directly execute it with its path.
# If you are not root, remember using `sudo`.
mv ./cli-helper /usr/local/bin/cli-helper
  1. cd to your project which will be packed, e.g. /home/ubuntu/your-project, and clean your dev dependencies.
cd /home/ubuntu/your-project
composer update --no-dev
  1. RUN cli-helper, pack current directory.

Notice: This command will ask you target phar path, entrypoint file name, etc.

cli-helper pack . app.phar
  1. Make phar executable
# add X permission
chmod +x /tmp/app.phar

# remove phar suffix, like a binary executable
mv /tmp/app.phar /tmp/your-app-name

# You can use it any way you like, for example, move to system PATH to execute it directly
cd /tmp
./your-app-name

mv your-app-name /usr/local/bin/
your-app-name

Make standalone binary executable with PHP (multiple arch supported)

Prepare your phar file packed through the above steps, we assume your phar name is your-app.phar.

# Download micro builds from `static-php-cli` project, remember check the latest PHP version from `https://dl.zhamao.xin/php-bin/file/` !
# You can change `x86_64` to `aarch64`, `armv7l`。
wget https://dl.zhamao.xin/php-bin/file/micro-8.0.19-x86_64.tar.gz
tar -zxvf micro-*.tar.gz
# Combine micro and your phar files
cat ./micro your-app.phar > your-app-standalone
chmod +x your-app-standalone

# Then just execute it anywhere, even your another machine have no php environment!
./your-app-standalone

Notice: This project is a complement to static-php-cli, for more details, check this link.

About

A helpful tool for your CLI php project, pack to phar, init new project with quality tools etc.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages