Overview
Oyta PHP Common is a versatile public package designed to streamline common development tasks with clean, static call methods. Built exclusively for PHP 8.0+, this toolkit integrates cryptographic functions, financial utilities, blockchain interactions, and more—all optimized for performance and ease of use.
Features
Core Functionalities
- Secure Password Handling: Salting and verification for enhanced security.
- Financial Tools: Money formatting with comma separation and dynamic currency conversion.
- Blockchain Integration: Address generation and transaction tracking for BTC, ETH, and TRON networks.
- Utilities: Random number generation, Google Authenticator management, and email dispatch.
Key Modules
- Cryptography: AES encryption/decryption and ECDSA key generation.
- Financial Data: Real-time stock data from Sina Finance and forex rate APIs.
- Invite Systems: Database-free invite code generation with UID mapping.
- Blockchain: Support for Taproot addresses (BTC), ERC-20/TRC-20 token transfers, and transaction history queries.
Installation
composer require oyta/commonUsage Examples
Password Management
$auth = new Common();
$credentials = $auth->setPass('user123');
$isValid = $auth->verPass($credentials['salt'], 'user123');Currency Formatting
$formatted = $auth->setFotMoney(123456.789, 2); // Returns "123,456.79"Blockchain Address Generation
$btcAddress = $auth->getBtcAddress(); // Generates new BTC Taproot address
$ethTransfers = $auth->getEthTokenTransferRecord('0x...'); // Queries ERC-20 transactionsFAQs
Q: How do I enable virtual currency features?
A: Ensure the gmp extension is active in your PHP environment.
Q: Can I use this package for commercial projects?
A: Absolutely! The package is MIT-licensed—modify and distribute freely.
Q: What’s the precision for money formatting?
A: Adjustable via the $decimals parameter (default: 2).
Q: How secure is the AES encryption?
A: Implements industry-standard 256-bit encryption with dynamic IVs.
Best Practices
👉 Explore advanced blockchain integrations for enterprise-grade solutions.
- Naming Conventions: Follows PSR-2/PSR-4 standards.
- Static Methods: Minimize memory overhead with pure static calls.
- Error Handling: Always validate outputs for cryptographic operations.
Advanced Implementations
ETH Token Transfer
$txHash = $auth->EthTokenTransfer(
$privateKey,
$senderAddress,
$recipient,
'1.5',
'0xdAC...' // USDT contract
);Custom Invite Codes
$inviteCode = $auth->setInvite(90210); // Generates "ABC123"
$uid = $auth->getInvite('ABC123'); // Returns 90210👉 Need high-volume transaction monitoring? OKX provides robust APIs for real-time tracking.
Compliance & Performance
- Platform Requirements: PHP 8.0+ with
gmpfor crypto features. - Dependencies: Zero external runtime dependencies—lightweight and fast.
- Static Analysis: Fully compatible with Psalm/PHPStan for type safety.
Contribution Guidelines
While primarily for personal use, community pull requests are welcome via GitHub. Ensure adherence to:
- PSR-12 coding standards.
- Comprehensive unit tests (PHPUnit).
- Clear documentation for new features.
Final Notes
This package consolidates years of development pain points into a single, optimized toolkit. Whether you’re handling microtransactions or building auth systems, Oyta Common delivers reliability without bloat.
🚀 Pro Tip: For low-latency applications, pre-initialize class methods during app bootstrap.