PHP code example of qit / helper

1. Go to this page and download the library: Download qit/helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

qit / helper example snippets


'providers' => [
    // Other service providers...
    Qit\Helper\HelperServiceProvider::class,
],

use Qit\Helper\functions\HelperGeneral;

// Generate an iframe (default)
$iframe = HelperGeneral::Youtube('https://www.youtube.com/watch?v=dQw4w9WgXcQ');

// Generate with custom dimensions
$iframe = HelperGeneral::Youtube(
    'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
    width: 800,
    height: 450,
    title: 'My Custom Video'
);

// Generate a clickable link instead of iframe
$link = HelperGeneral::Youtube(
    'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
    title: 'Watch Video',
    iframe: false
);

use Qit\Helper\functions\HelperGeneral;

// Basic resize - creates a cached version
HelperGeneral::ImgResize('image.jpg', 'uploads', 800, 600);

// Resize with small thumbnail
HelperGeneral::ImgResize(
    filename: 'image.jpg',
    path: 'uploads',
    weight: 800,
    height: 600,
    smallweight: 150,
    smallheight: 150
);

// Keep original aspect ratio (pass null for dimensions)
HelperGeneral::ImgResize('image.jpg', 'uploads', 'cache', 'small', 800, null);

// Custom folder names for cache and thumbnails
HelperGeneral::ImgResize('product.jpg', 'products', 'optimized', 'thumbs', 1200, 800, 200, 200);

use Qit\Helper\functions\HelperShop;

// Get a specific order status name
$statusName = HelperShop::getOrderStatusName(1);
// Returns: "Confirmed"

// Handle unknown status codes
$statusName = HelperShop::getOrderStatusName(999);
// Returns: "Unknown Status"

// Get all available order statuses
$allStatuses = HelperShop::getOrderStatusName(null, true);
// Returns: [
//     0 => 'Pending',
//     1 => 'Confirmed',
//     2 => 'Processing',
//     3 => 'Shipped',
//     4 => 'Cancelled',
//     5 => 'Delivered'
// ]

// Usage in a loop for displaying order status options
foreach (HelperShop::getOrderStatusName(null, true) as $code => $name) {
    echo "<option value='{$code}'>{$name}</option>";
}

try {
    HelperGeneral::ImgResize('image.jpg', 'uploads', 'cache', 'small', 800, 600);
    $status = HelperShop::getOrderStatusName(1);
} catch (Exception $e) {
    // Handle errors
    Log::error('Helper function failed: ' . $e->getMessage());
}

src/
├── HelperServiceProvider.php
└── functions/
    ├── HelperGeneral.php
    └── HelperShop.php