Home >Backend Development >PHP Tutorial >Introducing Lithe SwissHelper: Simplifying PHP Development
Meet Lithe SwissHelper, a lightweight yet powerful PHP utility library designed to simplify your development process. Whether for string manipulations, array operations, data validations or formatting tasks, SwissHelper has it all covered. With a focus on developer experience and clean, readable code, SwissHelper is here to make common programming tasks easier.
Getting started with SwissHelper is easy. Install it via Composer:
composer require lithephp/swisshelper
Once installed, include the Composer autoloader in your project:
require 'vendor/autoload.php';
SwissHelper offers intuitive methods for processing strings. Here are some examples:
$slug = str('Hello World!')->slug(); // Saída: "hello-world"
$numbers = str('Phone: (123) 456-7890')->onlyNumbers(); // Saída: "1234567890"
$masked = str('12345678901')->mask('###.###.###-##'); // Saída: "123.456.789-01"
Access and manipulate arrays with ease:
$array = ['user' => ['name' => 'John Doe']]; $name = arr($array)->get('user.name'); // Saída: "John Doe"
$filtered = arr(['a' => 1, 'b' => 2])->only(['a']); // Saída: ['a' => 1]
SwissHelper simplifies data validation with a robust set of validators:
validate('user@example.com')->email(); // Saída: true
validate('StrongP@ssw0rd')->password(); // Saída: true
$currentDate = now('Y-m-d'); // Saída: Data atual no formato 'YYYY-MM-DD'
$yesterday = now()->modify('-1 day'); // Saída: Objeto DateTime para ontem
Deal with monetary values in a simple way, with formatting for multiple currencies:
$formatted = money(1234.56, 'USD'); // Saída: ",234.56"
Generate random strings for various use cases:
composer require lithephp/swisshelper
require 'vendor/autoload.php';
$slug = str('Hello World!')->slug(); // Saída: "hello-world"
SwissHelper comes with a robust test suite. Run the tests with:
$numbers = str('Phone: (123) 456-7890')->onlyNumbers(); // Saída: "1234567890"
We'd love to have you on board! Fork the repository, create a branch for your functionality, and submit a pull request. Follow PSR-12 coding standards to maintain consistency.
Try SwissHelper today and experience a smoother PHP development experience. Share your ideas, report issues, and contribute on GitHub. Let's build something amazing together!
Find SwissHelper on Packagist: Lithe SwissHelper.
The above is the detailed content of Introducing Lithe SwissHelper: Simplifying PHP Development. For more information, please follow other related articles on the PHP Chinese website!