Skip to content

A collection of useful PHP CLI utilities (UUID, Hashing, JWT, Base64, Slugify, Timestamp, Password Generator)

License

Notifications You must be signed in to change notification settings

abramcatalyst/php-cli-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP CLI Tools

A collection of handy PHP CLI utilities for developers.

Tools

  • 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

Requirements

  • PHP 7.4 or higher
  • Composer

Installation

Install via Composer:

composer require abramcatalyst/php-cli-tools

Or add to your composer.json:

{
    "require": {
        "abramcatalyst/php-cli-tools": "^1.0"
    }
}

Usage

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 16

Or 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 16

UUID Generator

Generate a UUID v4:

vendor/bin/uuid
# Output: 550e8400-e29b-41d4-a716-446655440000

Password Hasher

Hash a password using bcrypt:

vendor/bin/hash mypassword
# Output: $2y$10$...

# With custom cost (4-31):
vendor/bin/hash mypassword 12

JWT Maker

Create 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-key

Timestamp Converter

Convert 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: 1700000000

Base64 Tool

Encode or decode base64:

# Encode
vendor/bin/base64tool encode "Hello World"
# Output: SGVsbG8gV29ybGQ=

# Decode
vendor/bin/base64tool decode "SGVsbG8gV29ybGQ="
# Output: Hello World

Slugify Tool

Convert 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-test

Random Password Generator

Generate a secure random password:

# Default length (16 characters)
vendor/bin/password

# Custom length (1-128 characters)
vendor/bin/password 32

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

About

A collection of useful PHP CLI utilities (UUID, Hashing, JWT, Base64, Slugify, Timestamp, Password Generator)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages