1. Go to this page and download the library: Download farzai/support 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/ */
use Farzai\Support\Str;
// Random alphanumeric (base64-like)
Str::random(16); // Returns: 'a3K7mN9pQ1xY2zB5'
// Random ASCII
Str::randomAscii(16);
// Random numeric only
Str::randomNumeric(6); // Returns: '472891'
// Random alphanumeric (A-Z, a-z, 0-9)
Str::randomAlphanumeric(12); // Returns: 'aB3xY9mK2nP7'
// Random with custom character set
Str::randomString(8, 'ABCD123'); // Returns: 'A2B1C3D2'
// Random with special characters (for passwords)
Str::randomStringWithSpecialCharacter(16); // Returns: 'aB3!xY@9#mK2$pQ5'
use Farzai\Support\Carbon;
use function Farzai\Support\now;
// Get current date/time
$now = now();
// or
$now = Carbon::now();
// With timezone
$now = now('America/New_York');
$now = Carbon::now('UTC');
// From timestamp
$date = Carbon::fromTimestamp(1609459200);
use Farzai\Support\Carbon;
$today = Carbon::now();
$yesterday = Carbon::yesterday();
$tomorrow = Carbon::tomorrow();
// Check if today
$today->isToday(); // Returns: true
$yesterday->isToday(); // Returns: false
// Check if past
$yesterday->isPast(); // Returns: true
$tomorrow->isPast(); // Returns: false
// Check if future
$tomorrow->isFuture(); // Returns: true
$yesterday->isFuture(); // Returns: false
// Check if between dates
$today->isBetweenDates($yesterday, $tomorrow); // Returns: true
use Farzai\Support\Carbon;
$date = Carbon::now();
// Format as date string
$date->toDateString(); // Returns: '2024-03-18'
// Format as time string
$date->toTimeString(); // Returns: '14:30:45'
// Format as datetime string
$date->toDateTimeString(); // Returns: '2024-03-18 14:30:45'
use Farzai\Support\Carbon;
$date = Carbon::now();
// Start of day
$start = $date->startOfDay(); // Returns: today at 00:00:00
// End of day
$end = $date->endOfDay(); // Returns: today at 23:59:59
use Farzai\Support\Carbon;
$today = Carbon::now();
$yesterday = Carbon::yesterday();
// Absolute difference in days
$today->diffInDaysAbsolute($yesterday); // Returns: 1
use function Farzai\Support\tap;
// With callback
$user = tap($user, function ($u) {
$u->update(['last_login' => now()]);
});
// Returns $user after updating
// Without callback (higher-order proxy)
$user = tap($user)
->update(['last_login' => now()])
->save();
// Chains methods but returns $user
use function Farzai\Support\now;
$current = now(); // Returns: Carbon instance
$ny = now('America/New_York'); // Returns: Carbon instance in NY timezone
use function Farzai\Support\class_basename;
class_basename('App\Models\User'); // Returns: 'User'
class_basename(new \App\Models\User); // Returns: 'User'
composer test
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.