sinevia / php-library-utils
PHP Library Utils
Installs: 1 489
Dependents: 6
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 2
Open Issues: 0
Requires (Dev)
- phpunit/phpunit: ^8.5
- sinevia/php-library-registry: ^2.0
README
The utility library provides multiple helper methods for PHP. These include methods for working with CSV, data, files, strings, etc.
Installation
1. Via Composer
composer require sinevia/php-library-utils
2. Manually
Download from https://github.com/Sinevia/php-library-utils
Usage
\Sinevia\Utils::raiseMemoryLimits();
Classes and methods
Array Utils
- columns splits the array into columns
\Sinevia\ArrayUtils::columns($array);
- isAssoc checks whether an array is associative
\Sinevia\ArrayUtils::isAssoc($array);
- toCsv converts an array to CSV. If the array is associative, the keys will be used for a header row
\Sinevia\ArrayUtils::toCsv($array, $forceQuotes=true);
Browser Utils
- fingerprint
\Sinevia\BrowserUtils::fingerprint();
Csv Utils
- write
\Sinevia\CsvUtils::write($filename, $array);
Data Utils
- serialize
\Sinevia\DataUtils::serialize($data, $pass);
- unserialize
\Sinevia\DataUtils::unserialize($data, $pass);
File Utils
Link Utils
- getBaseUrl
\Sinevia\LinkUtils::getBaseUrl(); // ""
- setBaseUrl
\Sinevia\LinkUtils::setBaseUrl("https://yahoo.com"); // ""
- buildUrl
\Sinevia\LinkUtils::buildUrl("/", ['a'=>'A', 'b'=>'B']); // "/?a=A&b=B"
String Utils
- between
\Sinevia\StringUtils::between("ABCDEFG","B","E"); // "CD"
- camelize
- endsWith
- fixNewLines - fixes \r\n to \n
- hasMinumumChars
- hasLowercase
- hasNumber
- hasOnly
- hasSubstring
- hasUppercase
- htmlEmailToText
- isEmail
\Sinevia\StringUtils::isEmail("test@test"); // false
- isJson
\Sinevia\StringUtils::isJson("ABC"); // false
- leftFrom
- maxWords
- p2br
- random
\Sinevia\StringUtils::rand(8); // "aBDhkDyD" \Sinevia\StringUtils::rand(8, "ABC"); // "BABCCB"
- regexSurround
- regexReplace
- rightFrom
- slugify
- snakify
- splitId
- startsWith
- substringBetween
- toArray
\Sinevia\StringUtils::toArray("ABC"); // ["A", "B", "C"]
- toWords
Utils
- arrayValueDelete
- colorNameToHex
- colorBrightness
- forceFileDownload
- forceFileDownloadFromContent
- getTimeAgo
- ip
\Sinevia\Utils::ip();
- isCli
- pagination
- paginationReversed
- pathToUrl
- percents
- redirectAndPostData
- redirect
- raiseMemoryLimits
- rssToArray