1. Go to this page and download the library: Download lithephp/swisshelper 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/ */
lithephp / swisshelper example snippets
// Get current DateTime object
$datetime = now();
// Get formatted current date
$formatted = now('Y-m-d H:i:s');
$date = now('Y-m-d');
$time = now('H:i:s');
// Check if age is within a range
validate('2000-01-01')->age(18, 60); // true
validate('2010-01-01')->age(18); // false
// Check if string or numeric value is between limits
validate('Hello')->between(3, 10); // true
validate(100)->between(50, 150); // true
// Check if string contains a specific substring
validate('Hello World')->contains('World'); // true
// Check if string starts or ends with specific text
validate('example.com')->startsWith('example'); // true
validate('example.com')->endsWith('.com'); // true
// Generate a random alphanumeric string of 16 characters
$alnum = random(16);
// Generate a random alphabetic string of 10 characters
$alpha = random(10, 'alpha');
// Generate a random numeric string of 8 characters
$numeric = random(8, 'numeric');
// Generate a random non-zero numeric string of 6 characters
$nozero = random(6, 'nozero');
// Get the current URL
$current = url()->current();
// Get the base URL
$base = url()->base();
// Generate a URL to a specific path
$path = url()->to('path/to/resource');
// Get the previous URL (referer)
$previous = url()->previous();
// Set a session variable
session()->put('key', 'value');
// Get a session variable
$value = session()->get('key');
// Check if a session variable exists
$exists = session()->has('key');
// Get all session variables
$all = session()->all();
// Unset a session variable
session()->forget('key');
// Destroy the session
session()->destroy();