PHPackages                             lithephp/swisshelper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lithephp/swisshelper

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lithephp/swisshelper
====================

Lithe SwissHelper is a comprehensive PHP utility library designed to simplify common programming tasks. It provides a collection of helper functions for string manipulation, array handling, data validation, and more, all designed with a focus on developer experience and code readability.

1.1.0(1y ago)311MITPHP

Since Jan 3Pushed 1y agoCompare

[ Source](https://github.com/lithephp/swisshelper)[ Packagist](https://packagist.org/packages/lithephp/swisshelper)[ RSS](/packages/lithephp-swisshelper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Lithe SwissHelper
=================

[](#lithe-swisshelper)

 [![Total Downloads](https://camo.githubusercontent.com/a1b770bcf985117c20c6b25d94130c3aebf0b6426cac2d6863dcb7661843777c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c697468657068702f737769737368656c706572)](https://packagist.org/packages/lithephp/swisshelper) [![Latest Stable Version](https://camo.githubusercontent.com/8aac24bde4ba3081560ff5b8774b1723a20e612b733600573b9140ba14dc9592/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c697468657068702f737769737368656c706572)](https://packagist.org/packages/lithephp/swisshelper) [![License](https://camo.githubusercontent.com/5ede56e9df4a7dd5e10b86ea4ac2317ad39e1d12f21124c11c5319f4b3fb1d14/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c697468657068702f737769737368656c706572)](https://packagist.org/packages/lithephp/swisshelper)

Introduction
------------

[](#introduction)

Lithe SwissHelper is a comprehensive PHP utility library designed to simplify common programming tasks. It provides a collection of helper functions for string manipulation, array handling, data validation, and more, all designed with a focus on developer experience and code readability.

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require lithephp/swisshelper
```

Detailed Function Documentation
-------------------------------

[](#detailed-function-documentation)

### DateTime Helper (now)

[](#datetime-helper-now)

The `now()` function provides a simple interface for datetime manipulation.

```
// 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');
```

### String Helper (str)

[](#string-helper-str)

The string helper provides various methods for string manipulation.

#### Creating Slugs

[](#creating-slugs)

```
$slug = str('Hello World!')->slug();
// Output: "hello-world"

$slug = str('Café com leite')->slug();
// Output: "cafe-com-leite"
```

#### Removing Accents

[](#removing-accents)

```
$text = str('Café à la crème')->removeAccents();
// Output: "Cafe a la creme"
```

#### Extracting Numbers

[](#extracting-numbers)

```
$numbers = str('Phone: (123) 456-7890')->onlyNumbers();
// Output: "1234567890"

$numbers = str('Order #123-456')->onlyNumbers();
// Output: "123456"
```

#### Applying Masks

[](#applying-masks)

```
// CPF (Brazilian ID)
$masked = str('12345678901')->mask('###.###.###-##');
// Output: "123.456.789-01"

// Phone number
$masked = str('1234567890')->mask('(##) ####-####');
// Output: "(12) 3456-7890"

// Custom mask
$masked = str('ABC123')->mask('???-###');
// Output: "ABC-123"
```

### Array Helper (arr)

[](#array-helper-arr)

The array helper provides methods for array manipulation and access.

#### Accessing Nested Arrays

[](#accessing-nested-arrays)

```
$array = [
    'user' => [
        'profile' => [
            'name' => 'John Doe',
            'settings' => [
                'theme' => 'dark'
            ]
        ]
    ]
];

// Access with dot notation
$name = arr($array)->get('user.profile.name');
// Output: "John Doe"

// With default value
$color = arr($array)->get('user.profile.color', 'blue');
// Output: "blue"
```

#### Selecting Specific Keys

[](#selecting-specific-keys)

```
$array = ['name' => 'John', 'age' => 30, 'email' => 'john@example.com'];

// Get only specific keys
$only = arr($array)->only(['name', 'email']);
// Output: ['name' => 'John', 'email' => 'john@example.com']

// Get everything except specified keys
$except = arr($array)->except(['age']);
// Output: ['name' => 'John', 'email' => 'john@example.com']
```

### Validation Helper (validate)

[](#validation-helper-validate)

The validation helper provides methods for validating different types of data.

#### Email Validation

[](#email-validation)

```
validate('email@example.com')->email(); // true
validate('invalid-email')->email(); // false
```

#### URL Validation

[](#url-validation)

```
validate('https://example.com')->url(); // true
validate('invalid-url')->url(); // false
```

#### IP Address Validation

[](#ip-address-validation)

```
validate('192.168.1.1')->ip(); // true
validate('256.256.256.256')->ip(); // false
```

#### Date Validation

[](#date-validation)

```
validate('2024-01-03')->date(); // true
validate('2024-13-45')->date(); // false

// Custom format
validate('03/01/2024')->date('d/m/Y'); // true
```

#### Name Validation

[](#name-validation)

```
validate('John Doe')->name(); // true
validate('John123')->name(); // false
```

#### Credit Card Validation

[](#credit-card-validation)

```
validate('4532015112830366')->creditCard(); // true
validate('1234567890123456')->creditCard(); // false
```

#### Password Validation

[](#password-validation)

```
// Validate password strength
validate('P@ssw0rd')->password(); // true
validate('weak')->password(); // false

// Custom rules
validate('1234Abcd!')->password(8, false, true, true, true); // true
```

#### Age Validation

[](#age-validation)

```
// Check if age is within a range
validate('2000-01-01')->age(18, 60); // true
validate('2010-01-01')->age(18); // false
```

#### Value Length Validation

[](#value-length-validation)

```
// Check if string or numeric value is between limits
validate('Hello')->between(3, 10); // true
validate(100)->between(50, 150); // true
```

#### String Search Validation

[](#string-search-validation)

```
// 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
```

### Random String Generator (random)

[](#random-string-generator-random)

The `random()` function generates random strings of various types.

```
// 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');
```

### URL Helper (url)

[](#url-helper-url)

The URL helper provides methods for handling URLs.

```
// 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();
```

### Session Helper (session)

[](#session-helper-session)

The session helper provides methods for managing session data.

```
// 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();
```

### CSRF Helpers

[](#csrf-helpers)

#### CSRF Token

[](#csrf-token)

```
$token = csrf_token();
```

#### CSRF Hidden Field

[](#csrf-hidden-field)

```
$field = csrf_field();
// Output:
```

Contributing
------------

[](#contributing)

Contributions are welcome and will be fully credited. Please follow these steps:

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

Support
-------

[](#support)

Create an issue in the GitHub repository.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance44

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~55 days

Total

2

Last Release

445d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/56173de3a7bf7099dd8168efd730d3c2fb5df5174a123fdc37cee8c3589e2345?d=identicon)[williamhumbwavali](/maintainers/williamhumbwavali)

---

Top Contributors

[![williamhumbwavali](https://avatars.githubusercontent.com/u/127023095?v=4)](https://github.com/williamhumbwavali "williamhumbwavali (4 commits)")

---

Tags

helpershelpers-librarylibrarylithephp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lithephp-swisshelper/health.svg)

```
[![Health](https://phpackages.com/badges/lithephp-swisshelper/health.svg)](https://phpackages.com/packages/lithephp-swisshelper)
```

###  Alternatives

[astrotomic/laravel-webmentions

215.7k](/packages/astrotomic-laravel-webmentions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
