{"id":19029966,"url":"https://github.com/padosoft/support","last_synced_at":"2026-02-25T11:15:31.969Z","repository":{"id":57035027,"uuid":"66027815","full_name":"padosoft/support","owner":"padosoft","description":"Collection of agnostic PHP Functions and helpers with zero dependencies to use as foundation in packages and other project","archived":false,"fork":false,"pushed_at":"2024-07-25T09:32:22.000Z","size":473,"stargazers_count":51,"open_issues_count":0,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-19T10:04:55.819Z","etag":null,"topics":["helpers","php-library","php7","support-library"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/padosoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-18T20:16:52.000Z","updated_at":"2024-07-25T19:24:08.000Z","dependencies_parsed_at":"2022-08-23T20:50:50.407Z","dependency_job_id":null,"html_url":"https://github.com/padosoft/support","commit_stats":null,"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Fsupport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Fsupport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Fsupport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Fsupport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/padosoft","download_url":"https://codeload.github.com/padosoft/support/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235700131,"owners_count":19031671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["helpers","php-library","php7","support-library"],"created_at":"2024-11-08T21:15:57.308Z","updated_at":"2025-10-08T09:31:37.247Z","avatar_url":"https://github.com/padosoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Collection of agnostic PHP Functions and helpers\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/padosoft/support.svg?style=flat-square)](https://packagist.org/packages/padosoft/support)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Build Status](https://img.shields.io/travis/padosoft/support/master.svg?style=flat-square)](https://travis-ci.org/padosoft/support)\n[![Quality Score](https://img.shields.io/scrutinizer/g/padosoft/support.svg?style=flat-square)](https://scrutinizer-ci.com/g/padosoft/support)\n[![Total Downloads](https://img.shields.io/packagist/dt/padosoft/support.svg?style=flat-square)](https://packagist.org/packages/padosoft/support)\n\nThis package provides a lot of very usefull agnostic helpers to use as foundation in packages and other project.\n\n**NOTE:**\nSome of these helpers was written by padosoft, another was founded on the opensource web and some of these is refactored and/or adjusted for our purpose or for improvements.\n\n##Overview\n\nAll helpers function are splitted into these files:\n\n- Array\n- Constants (generic usefull constants)\n- DateTime\n- Helpers (misc functions)\n- IP\n- Reflection\n- Sanitize\n- String\n- Validation\n- Xml\n\n##Requires\n  \n- php: \u003e=7.0.0|^8.0|^8.1\n- nesbot/carbon (only for some datetime functions)\n  \n## Installation\n\nYou can install the package via composer:\n```bash\n$ composer require padosoft/support\n```\n\n## Usage\n\nCreate new php file, add composer autoload and start using functions.\n\n```php\n\u003c?php\n\nrequire \"vendor/autoload.php\";\n\nvar_dump(str_random(16));\n```\n\n## List of functions\n\n### Array\n- head\n- last\n- insert_at_top\n- array_has\n- array_get\n- array_set\n- CleanUpArrayOfInt\n- array_split_filter\n- in_array_column\n- objectToArray\n- arrayToObject\n- arrayToString\n- array_key_exists_safe\n- array_get_key_value_safe\n- isNullOrEmptyArray\n- isNotNullOrEmptyArray\n- isNullOrEmptyArrayKey\n- isNotNullOrEmptyArrayKey\n- array_remove_columns() : Remove given column from the subarrays of a two dimensional array.\n- array_remove_first_columns() : Remove first column from the subarrays of a two dimensional array.\n- array_remove_last_columns()  : Remove last column from the subarrays of a two dimensional array.\n\n### DateTime\n- carbonFromIsoDateTime\n- carbonFromIsoDate\n- carbonFromItaDateTime\n- carbonFromItaDate\n- carbon\n- roman_year\n- partialsDateIso\n- dateIsoToIta\n- dateItaToIso\n- monthFromNumber\n- dateIsoToItaSpec\n- getNameDayFromDateIso\n- getTimeFromDateTimeIso\n- diff_in_year\n- age\n- ampm\n- ampm2Number\n- fuzzySpan\n- unixTimestamp2dos\n- dos2unixTimestamp\n- cal_days_in_month\n- cal_days_in_current_month\n- days_in_month\n- days_in_current_month\n\n\n### Helpers (misc functions)\n- rgb2hex\n- hex2rgb\n- format_money\n- format_euro\n- ordinal\n- value\n- with\n- setErrorReportingForProduction\n- isExecutedByCLI\n- bytes2HumanSize\n- convertPHPSizeToBytes\n- getMaximumFileUploadSize\n- encryptString\n- getFaviconUrl\n- getFaviconImgTag\n- isHttps\n- getQRcode\n- getQRcodeUrl\n- gravatarUrl\n- gravatar\n- isNumberOdd\n- isNumberEven\n- getTinyUrl\n- expandShortUrl\n- curl\n- curl_internal_server_behind_load_balancer\n- debug\n- isAjax\n- isMobile\n- getBrowser\n- getReferer\n- getCurrentURL\n- getCurrentUrlPageName\n- getCurrentUrlQuerystring\n- getCurrentUrlDirName\n- getCurrentUrlDirAbsName\n- isZlibOutputCompressionActive\n- isZlibLoaded\n- isClientAcceptGzipEncoding\n- compressHtmlPage\n- get_http_response_code\n- url_exists\n- startLayoutCapture\n- endLayoutCapture\n- get_var_dump_output\n- logToFile\n- isImageExtension\n- getImageExtensions\n- template\n- randomChance\n- getExceptionTraceAsString\n- windows_os\n- getConsoleColorTagForStatusCode() : Get the color tag for the given status code to be use in symfony/laravel console.\n- get_os_architecture() : Get the OS architecture 32 or 64 bit.\n- is_32bit() : Check if the OS architecture is 32bit.\n- is_64bit() : Check if the OS architecture is 64bit.\n- isRequestFromCloudFlare(): check if request (by given $_SERVER) is a cloudflare request.\n- isCloudFlareIp(): check if given ip is a valid cloudflare ip. \n- gzCompressFile(): GZIPs a file on disk (appending .gz to the name) without read all source file in memory.\n- getFileMimeType(): get the mime type string of a file using more strategies or return FALSE if it fails.\n- getFileMimeTypeByFileInfo(): get File MimeType string using the newer PHP finfo functions.\n- getFileMimeTypeByOSFileCommand(): get File MimeType string using the OS' file command. AFAIK that's only available on *NIX systems.\n- getImageMimeTypeByExif_imagetype(): get image MimeType string of image using exif_imagetype.\n      \n### IP\n- getIPVisitor\n- anonimizeIp\n- anonimizeIpv4() : masquerade last digit of IPv4 address.\n- anonimizeIpv4Compatibility() : masquerade last digit of IPv4 compatibility address.\n- anonimizeIpv6() : masquerade last digit of IPv6 address.\n- anonimizeIpWithInet() : masquerade last digit of IP address with inet php function.\n- getHost\n- getClientIps\n- getClientIp\n- checkIp\n- checkIp4\n- checkIp6\n- isFromTrustedProxy\n- expandIPv6Notation(): * Replace '::' with appropriate number of ':0'\n- decbin32(): to ensure that the binary strings are padded with zeros out to 32 characters.\n- ipInRange(): Function to determine if an IP is located in a specific range as specified via several alternative formats.\n\n### Reflection\n- short_class_name\n- class_constants\n- class_uses_recursive\n- class_basename\n- getClassNameFromFile\n- getNamespaceFromFile\n- getPhpDefinitionsFromFile\n\n### Sanitize\n- strip_nl\n- jse : Escape javascript argument.\n- e : Escape html argument.\n- csse : Escape css argument.\n- attre : Escape html attribute argument.\n- she() : Escape shell argument.\n- normalizeUtf8String : Normalize the string. Removes all diacritics (marks like accents) from a given UTF8-encoded texts and returns ASCii-text.\n- normalizerUtf8Safe() : Normalize uft8 to various form with php normalizer function if exists, otherwise return original string.\n- sanitize_filename\n- sanitize_pathname\n- sanitize_arr_string_xss\n- sanitize_string_xss\n- sanitize_urlencode\n- sanitize_email\n- sanitize_numbers\n- sanitize_floats\n- sanitize_phone() : Sanitize the string by removing illegal characters from phone numbers.\n\n### String\n\n- generateRandomPassword\n- generateRandomString\n- preg_replace_sub\n- snake_case\n- str_random\n- ends_with\n- ends_with_insensitive\n- starts_with\n- starts_with_insensitive\n- str_contains\n- str_contains_insensitive\n- str_finish\n- str_finish_insensitive\n- str_is\n- str_limit\n- str_replace_array\n- studly_case\n- studly\n- camel_case\n- underscore2dash\n- dash2underscore\n- str_replace_multiple_space\n- str_replace_last\n- segment\n- firstSegment\n- lastSegment\n- isNullOrEmpty\n- isNotNullOrEmpty\n- numberToWord\n- secondsToText\n- minutesToText\n- hoursToText\n- str_html_compress\n- str_word_count_utf8\n- slugify() : Generate a URL friendly \"slug\" from a given string.\n- firstStringBetween(): Returns the first string there is between the strings from the parameter start and end.\n\n### Validation\n\n- isStringNumberStartsWithMoreThanOneZero\n- isIntegerPositive\n- isIntegerPositiveOrZero\n- isIntegerNegative() : Check if the value (int, float or string) is a integer and less than zero.\n- isIntegerNegativeOrZero() : Check if the value (int, float or string) is a integer and less than zero or equals to zero.\n- isIntegerZero() : Check if the value (int, float or string) is a integer and equals to zero.\n- isInteger\n- isIntegerFloatingPoint\n- isFloatingPoint\n- isDouble\n- isPercent\n- isIntBool() : Check if the value is a integer/string 0 or 1.\n- isDateIta\n- isDateIso\n- isDateTimeIso\n- isDateTimeIta\n- isTimeIso\n- isTimeIta\n- isDateZeroIso() : Check if string is 0000-00-00\n- isTimeZeroIso() : Check if string is 00:00:00\n- isDateTimeZeroIso() : Check if string is '0000-00-00 00:00:00' \n- isDateOrDateZeroIso() : Check if string is YYYY-mm-dd and valid date or 0000-00-00 \n- isDateTimeOrDateTimeZeroIso() : Check if string is 'YYYY-mm-dd HH:ii:ss' and valid date or '0000-00-00 00:00:00' \n- isDateZeroIta() : Check if string is 00/00/0000\n- isTimeZeroIta() : Check if string is 00:00:00\n- isDateTimeZeroIta() : Check if string is '00/00/0000 00:00:00' \n- isDateOrDateZeroIta() : Check if string is dd/mm/YYYY and valid date or 00/00/0000 \n- isDateTimeOrDateTimeZeroIta() : Check if string is 'dd/mm/YYYY HH:ii:ss' and valid date or '00/00/0000 00:00:00' \n- hasMinAge\n- hasMaxAge\n- hasAgeInRange\n- isInRange\n- isDay\n- isMonth\n- isJewishLeapYear\n- betweenDateIso\n- betweenDateIta\n- isMail\n- isIPv4\n- isIPv6\n- isIPv4Compatibility\n- isIP\n- isUrl\n- isHostname\n- urlW3c\n- isVATRegisteredInVies() : Validate a European VAT number using the EU commission VIES service to verify if VAT number is authorized to carry out intra-Community operations must use the service.\n- isITVat() : Check Italian Vat Number (Partita IVA).\n- isEuVatNumber() : Check if a valid EU vat given against specific EU country vat rules (at the moment only for italy) and optionally check the EU VIES service.\n- getCoutryCodeByVatNumberTest($val, $fallback): Try to extract EU country code in Vat number return $fallback if it fails.   \n- isCf\n- isAlpha\n- isAlphaNumeric\n- isAlphaNumericDash\n- isAlphaNumericWhiteSpaces\n- isNumeric() : Determine if the provided value contains only numeric characters with or without(default) sign.\n- isNumericWithSign() : Determine if the provided value contains only numeric characters with sign.\n- isNumericWithoutSign() : Determine if the provided value contains only numeric characters without sign.\n- isBool\n- isBoolOrIntBool\n- isCrediCard\n- isValidHumanName\n- isIban\n- hasFileExtension\n- isphoneNumber\n- isJsonString\n- isUuid\n- isGeoCoordinate\n- isLatitude\n- isLongitude\n- isAscii\n- isUtf8\n\n### Xml\n- xmlUrl2array\n- xml2array\n- array2xml\n- array2SimpleXMLElement\n\n### Constants (generic usefull constants)\n- DS\n- NUMBERS_ITA_ARR\n- NUMBERS_EN_ARR\n- PERIOD_IN_SECONDS_ITA_ARR\n- PERIOD_SINGULAR_PLURAL_ITA_ARR\n- PERIOD_IN_SECONDS_EN_ARR\n- SECOND_IN_SECOND\n- MINUTE_IN_SECOND\n- HOUR_IN_SECOND\n- DAY_IN_SECOND\n- WEEK_IN_SECOND\n- MONTH_IN_SECOND\n- YEAR_IN_SECOND\n- DATE_TIME_FORMAT_ISO\n- DATE_TIME_FORMAT_ITA\n- DATE_FORMAT_ISO\n- DATE_FORMAT_ITA\n- TIME_FORMAT_ISO\n- TIME_FORMAT_ITA\n- SUNDAY\n- MONDAY\n- TUESDAY\n- WEDNESDAY\n- THURSDAY\n- FRIDAY\n- SATURDAY\n- DAYS_ITA_ARR\n- DAYS_ENG_ARR\n- GENNAIO\n- FEBBRAIO\n- MARZO\n- APRILE\n- MAGGIO\n- GIUGNO\n- LUGLIO\n- AGOSTO\n- SETTEMBRE\n- OTTOBRE\n- NOVEMBRE\n- DICEMBRE\n- MONTHS_ITA_ARR\n- MONTHS_ITA_ARR_1_BASED\n- MONTHS_SHORT_ITA_ARR\n- MONTHS_SHORT_ITA_ARR_1_BASED\n\n## Usage\n\nYou can call every functions directly.\nExample:\n\n```php\n\u003c?php\n\n/*\n *  constans\n */\necho 'directory separator is: '.DS;\n\n/*\n *  validation helpers\n */\n\n//check iso date\nif( !isDateIso(\"\") )  echo 'invalid.';\nif( !isDateIso(\"2016-08-18\") )  echo 'invalid.';\nif( !isDateIso(\"2016-18-08\") )  echo 'invalid.';\nif( !isDateIso(\"0000-00-00\") )  echo 'invalid.';\nif( !isDateIso(\"00-00-00\") )  echo 'invalid.';\nif( !isDateIso(\"16-08-18\") )  echo 'invalid.';\nif( !isDateIso(\"2016-02-38\") )  echo 'invalid.';\n\n//check italian Fiscal Code\nif( !isCf(\"\") )  throw new Exception();\nif( !isCf(\"abcdefghijklmnoz\") )  throw new Exception();\nif( !isCf(\"xxxxxx12c34x567o\") )  throw new Exception();\n\n//check italian VAT (Partita iva)\nif( !isPiva(\"\") )  throw new Exception();\nif( !isCf(\"00000000000\") )  throw new Exception();\nif( !isCf(\"02361141209\") )  throw new Exception();\nif( !isCf(\"00000000001\") )  throw new Exception();\n\n//check integer value\nif( !isInteger(1561) )  throw new Exception();\nif( !isInteger('sadasd') )  throw new Exception();\n\n/*\n *  datetime helpers\n */\n\n//sleep 2 minuti\nsleep(2*MINUTE_IN_SECOND);\n//sleep 2h\nsleep(2*HOUR_IN_SECOND);\n//sleep 2min and 30seconds\nsleep(2*MINUTE_IN_SECOND+30);\n\n//date format\necho date(DATE_FORMAT_ISO);//'Y-m-d' \necho date(DATE_FORMAT_ITA);//'d-m-Y'\necho date(DATE_TIME_FORMAT_ISO);//'Y-m-d H:i:s'\n\n//date conversion\necho dateIsoToIta('2016-08-18');//08/18/2016\n\n//days and month\necho DAYS_ITA_ARR[0];//Lunedi\necho DAYS_ITA_ARR[date('w')];\necho MONTHS_ITA_ARR_1_BASED[12];//Dicembre\necho MONTHS_ITA_ARR_1_BASED[date('j')];\n\n//misc\necho roman_year(50);//L\necho roman_year(10);//X\necho roman_year(2000);//MM\necho roman_year(2016);//MMXVI\n\n/**\n* String\n */\necho str_random(16);\n\n```\n\nNOTA: for full list of helpers functions, see the code in /src. \n\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email instead of using the issue tracker.\n\n## Credits\n- [Lorenzo Padovani](https://github.com/lopadova)\n- [All Contributors](../../contributors)\n\n## About Padosoft\nPadosoft (https://www.padosoft.com) is a software house based in Florence, Italy. Specialized in E-commerce and web sites.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpadosoft%2Fsupport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpadosoft%2Fsupport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpadosoft%2Fsupport/lists"}