A collection of handy PHP CLI utilities for developers.
- UUID Generator - Generate UUID v4 (random UUIDs)
- Password Hasher - Hash passwords using bcrypt
- JWT Maker - Create JWT tokens with HS256 algorithm
- Timestamp Converter - Convert between timestamps and human-readable dates
- Base64 Tool - Encode/decode base64 strings
- Slugify Tool - Convert text to URL-friendly slugs
- Random Password Generator - Generate secure random passwords
- PHP 7.4 or higher
- Composer
Install via Composer:
composer require abramcatalyst/php-cli-toolsOr add to your composer.json:
{
"require": {
"abramcatalyst/php-cli-tools": "^1.0"
}
}After installation, the CLI tools will be available in vendor/bin/:
# Using vendor/bin directly
./vendor/bin/uuid
./vendor/bin/hash mypassword
./vendor/bin/jwt '{"id":1}'
./vendor/bin/timestamp
./vendor/bin/base64tool encode "Hello"
./vendor/bin/slug "Hello World"
./vendor/bin/password 16Or if you have Composer's bin directory in your PATH, you can use them directly:
uuid
hash mypassword
jwt '{"id":1}'
timestamp
base64tool encode "Hello"
slug "Hello World"
password 16Generate a UUID v4:
vendor/bin/uuid
# Output: 550e8400-e29b-41d4-a716-446655440000Hash a password using bcrypt:
vendor/bin/hash mypassword
# Output: $2y$10$...
# With custom cost (4-31):
vendor/bin/hash mypassword 12Create a JWT token:
# With default secret
vendor/bin/jwt '{"id":1,"name":"John"}'
# With custom secret
vendor/bin/jwt '{"id":1,"name":"John"}' my-secret-keyConvert timestamps to dates or dates to timestamps:
# Show current timestamp and date
vendor/bin/timestamp
# Convert timestamp to date
vendor/bin/timestamp 1700000000
# Output: 2023-11-14 22:13:20
# Convert date to timestamp
vendor/bin/timestamp "2023-11-14 22:13:20"
# Output: 1700000000Encode or decode base64:
# Encode
vendor/bin/base64tool encode "Hello World"
# Output: SGVsbG8gV29ybGQ=
# Decode
vendor/bin/base64tool decode "SGVsbG8gV29ybGQ="
# Output: Hello WorldConvert text to a URL-friendly slug:
vendor/bin/slug "Hello World!"
# Output: hello-world
vendor/bin/slug "This is a Test!!!"
# Output: this-is-a-testGenerate a secure random password:
# Default length (16 characters)
vendor/bin/password
# Custom length (1-128 characters)
vendor/bin/password 32Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details.