PHPackages                             squirrelphp/strings-bundle - 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. squirrelphp/strings-bundle

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

squirrelphp/strings-bundle
==========================

Symfony integration of squirrelphp/strings - make squirrel strings functionality easily available in Symfony

v3.0(1mo ago)23.0kMITPHPPHP &gt;=8.4

Since Jul 10Pushed 5mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (20)Versions (21)Used By (0)

Squirrel Strings Integration for Symfony
========================================

[](#squirrel-strings-integration-for-symfony)

[![Build Status](https://camo.githubusercontent.com/8526a558ebe91e8428c37fe9f1b11c4ff411eec127fc10940315b02be6e09f47/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f737175697272656c7068702f737472696e67732d62756e646c652e737667)](https://travis-ci.com/squirrelphp/strings-bundle) [![Test Coverage](https://camo.githubusercontent.com/210842e7a7aeb6048f89ffa940462b545bc66c21548ed47ceeb448c488e8c18d/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f66366530663762393166323636373837636530632f746573745f636f766572616765)](https://codeclimate.com/github/squirrelphp/strings-bundle/test_coverage) [![PHPStan](https://camo.githubusercontent.com/65e2c93fbe63f94af93706ba48d15eafa85a0cd4ff0c5aeea712b4da080d7545/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230382d737563636573732e7376673f7374796c653d666c61742d726f756e64266c6162656c3d7068707374616e)](https://camo.githubusercontent.com/65e2c93fbe63f94af93706ba48d15eafa85a0cd4ff0c5aeea712b4da080d7545/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c253230382d737563636573732e7376673f7374796c653d666c61742d726f756e64266c6162656c3d7068707374616e) [![Packagist Version](https://camo.githubusercontent.com/b897f194478973d35e4aea8532a171f99e684507b820ea4c37212dff1afe7ce1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737175697272656c7068702f737472696e67732d62756e646c652e7376673f7374796c653d666c61742d726f756e64)](https://packagist.org/packages/squirrelphp/strings-bundle) [![PHP Version](https://camo.githubusercontent.com/e3160e0e5b6144fece3430638ad4e08ad5e6985598f2a19aa0c19720892dc25f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f737175697272656c7068702f737472696e67732d62756e646c652e737667)](https://packagist.org/packages/squirrelphp/strings-bundle) [![Software License](https://camo.githubusercontent.com/4f9c8f8c009336d7177cf697d694e2e763e5e707f1a6224ab0d295465eadffbd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d737563636573732e7376673f7374796c653d666c61742d726f756e64)](LICENSE)

Integration of [squirrelphp/strings](https://github.com/squirrelphp/strings) into a Symfony project through service tags and bundle configuration.

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

[](#installation)

```
composer require squirrelphp/strings-bundle

```

Configuration
-------------

[](#configuration)

Enable the bundle by adding `Squirrel\StringsBundle\SquirrelStringsBundle` to the list of your used bundles. The bundle then configures itself automatically.

Usage
-----

[](#usage)

### String filters

[](#string-filters)

The default filters are grouped in six categories (links go to `squirrelphp/strings` documentation):

#### [Newlines, tabs and spaces](https://github.com/squirrelphp/strings#newlines-tabs-and-spaces)

[](#newlines-tabs-and-spaces)

- [NormalizeNewlinesToUnixStyle](https://github.com/squirrelphp/strings#normalizenewlinestounixstyle)
- [ReplaceUnicodeWhitespaces](https://github.com/squirrelphp/strings#replaceunicodewhitespaces)
- [RemoveExcessSpaces](https://github.com/squirrelphp/strings#removeexcessspaces)
- [LimitConsecutiveUnixNewlinesToTwo](https://github.com/squirrelphp/strings#limitconsecutiveunixnewlines)
- [RemoveZeroWidthSpaces](https://github.com/squirrelphp/strings#removezerowidthspaces)
- [ReplaceNewlinesWithSpaces](https://github.com/squirrelphp/strings#replacenewlineswithspaces)
- [Trim](https://github.com/squirrelphp/strings#trim)
- [ReplaceTabsWithSpaces](https://github.com/squirrelphp/strings#replacetabswithspaces)
- [WrapLongWordsNoHTML20Chars](https://github.com/squirrelphp/strings#wraplongwordsnohtml)
- [WrapLongWordsWithHTML20Chars](https://github.com/squirrelphp/strings#wraplongwordswithhtml)

#### [Cases: lowercase, uppercase, camelcase, snakecase](https://github.com/squirrelphp/strings#cases-lowercase-uppercase-camelcase-snakecase)

[](#cases-lowercase-uppercase-camelcase-snakecase)

- [Lowercase](https://github.com/squirrelphp/strings#lowercase)
- [Uppercase](https://github.com/squirrelphp/strings#uppercase)
- [UppercaseFirstCharacter](https://github.com/squirrelphp/strings#uppercasefirstcharacter)
- [UppercaseWordsFirstCharacter](https://github.com/squirrelphp/strings#uppercasewordsfirstcharacter)
- [CamelCaseToSnakeCase](https://github.com/squirrelphp/strings#camelcasetosnakecase)
- [SnakeCaseToCamelCase](https://github.com/squirrelphp/strings#snakecasetocamelcase)

#### [HTML](https://github.com/squirrelphp/strings#html)

[](#html)

- [RemoveHTMLTags](https://github.com/squirrelphp/strings#removehtmltags)
- [RemoveHTMLTagCharacters](https://github.com/squirrelphp/strings#removehtmltagcharacters)
- [ReplaceUnixStyleNewlinesWithParagraphs](https://github.com/squirrelphp/strings#replaceunixstylenewlineswithparagraphs)
- [EncodeBasicHTMLEntities](https://github.com/squirrelphp/strings#encodebasichtmlentities)
- [DecodeBasicHTMLEntities](https://github.com/squirrelphp/strings#decodebasichtmlentities)
- [DecodeAllHTMLEntities](https://github.com/squirrelphp/strings#decodeallhtmlentities)

#### [Remove/restrict characters and content](https://github.com/squirrelphp/strings#remove-restrict-characters-and-content)

[](#removerestrict-characters-and-content)

- [RemoveNonUTF8Characters](https://github.com/squirrelphp/strings#removenonutf8characters)
- [RemoveNonAlphanumeric](https://github.com/squirrelphp/strings#removenonalphanumeric)
- [RemoveNonAlphabetic](https://github.com/squirrelphp/strings#removenonalphabetic)
- [RemoveNonNumeric](https://github.com/squirrelphp/strings#removenonnumeric)
- [RemoveNonAsciiAndControlCharacters](https://github.com/squirrelphp/strings#removenonasciiandcontrolcharacters)
- [RemoveEmails](https://github.com/squirrelphp/strings#removeemails)
- [RemoveURLs](https://github.com/squirrelphp/strings#removeurls)

#### [Normalize to ASCII](https://github.com/squirrelphp/strings#normalize-to-ascii)

[](#normalize-to-ascii)

- [NormalizeLettersToAscii](https://github.com/squirrelphp/strings#normalizeletterstoascii)
- [NormalizeToAlphanumeric](https://github.com/squirrelphp/strings#normalizetoalphanumeric)
- [NormalizeToAlphanumericLowercase](https://github.com/squirrelphp/strings#normalizetoalphanumericlowercase)
- [ReplaceNonAlphanumericWithDash](https://github.com/squirrelphp/strings#replacenonalphanumeric)

#### [Streamline input](https://github.com/squirrelphp/strings#streamline-input)

[](#streamline-input)

- [StreamlineInputWithNewlines](https://github.com/squirrelphp/strings#streamlineinputwithnewlines)
- [StreamlineInputNoNewlines](https://github.com/squirrelphp/strings#streamlineinputnonewlines)

You can typehint `Squirrel\Strings\StringFilterSelectInterface` to get a service where all filters are accessible via the getFilter method:

```
function (\Squirrel\Strings\StringFilterSelectInterface $selector) {
    $string = "hello\n\nthanks a lot!\nbye";

    $string = $selector->getFilter('ReplaceNewlinesWithSpaces')
        ->filter($string);

    // Outputs "hello  thanks a lot! bye"
    echo $string;
}
```

You can also directly typehint a filter class, like `Squirrel\Strings\Filter\NormalizeToAlphanumeric` - all classes are registered as services in Symfony with their class names. All filter classes can also be instantiated in your application.

#### Form string filtering

[](#form-string-filtering)

This bundle automatically configures string filters for your form values that you can use via attributes, example:

```
