2017 © Pedro Pelรกez
 

library upgradephp

Mirror of http://include-once.org/p/upgradephp/

image

4picht/upgradephp

Mirror of http://include-once.org/p/upgradephp/

  • Tuesday, July 5, 2016
  • by 4picht
  • Repository
  • 1 Watchers
  • 0 Stars
  • 41 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

UpgradePHP

This is Git clone of the amazing UpgradePHP project. It's a shim/polyfill for PHP 5.3/5.4 functions for PHP 4.1 to PHP 5.1 installations. I wanted it on Git since I mostly work via Git and not the fossil DVCS. The below information is copied from the official sources. It can be adapted to be autoloaded from composer. But it's probably better for you to pick and choose which polyfills you want., (*1)

  • Version: 19.1
  • Official Site: http://include-once.org/p/upgradephp
  • Official Repository: http://fossil.include-once.org/upgradephp

Explanation

With 'upgrade.php' on-hand, you can use many features from newer PHP versions (up to 5.3/5.4 currently) without losing compatibility to older interpreters and outdated webserver setups. It takes care of emulating any functions (with their original names) that are missing at runtime., (*2)

You just include() it into your application. Then you're freed from micromanaging backwards compliance and wasting time with workarounds. Simply use the more featureful PHP functions., (*3)

Following functions are currently emulated: gzdecode ยท hex2bin ยท class_uses ยท zlib_encode ยท zlib_decode ยท session_status ยท http_response_code ยท http_redirect ยท http_send_content_type ยท json_encode ยท json_decode ยท preg_filter ยท lcfirst ยท array_replace ยท strptime ยท error_get_last ยท preg_last_error ยท lchown ยท lchgrp ยท ob_get_headers ยท xmlentities ยท stripos ยท strripos ยท str_ireplace ยท get_headers ยท headers_list ยท fprintf ยท vfprintf ยท str_split ยท http_build_query ยท convert_uuencode ยท convert_uudecode ยท scandir ยท idate ยท time_nanosleep ยท strpbrk ยท php_real_logo_guid ยท php_egg_logo_guid ยท php_strip_whitespace ยท php_check_syntax ยท get_declared_interfaces ยท array_combine ยท array_walk_recursive ยท substr_compare ยท spl_classes ยท class_parents ยท session_commit ยท dns_check_record ยท dns_get_mx ยท setrawcookie ยท file_put_contents ยท file_get_contents ยท fnmatch ยท glob ยท array_key_exists ยท array_intersect_assoc ยท array_diff_assoc ยท html_entity_decode ยท str_word_count ยท str_shuffle ยท get_include_path ยท set_include_path ยท restore_include_path ยท str_rot13 ยท array_change_key_case ยท array_fill ยท array_chunk ยท md5_file ยท is_a ยท fmod ยท floatval ยท is_infinite ยท is_nan ยท is_finite ยท var_export ยท strcoll ยท diskfreespace ยท disktotalspace ยท vprintf ยท vsprintf ยท import_request_variables ยท hypot ยท log1p ยท expm1 ยท sinh ยท cosh ยท tanh ยท asinh ยท acosh ยท atanh ยท array_udiff_uassoc ยท array_udiff_assoc ยท array_diff_uassoc ยท array_udiff ยท array_uintersect_uassoc ยท array_uintersect_assoc ยท array_uintersect ยท array_intersect_uassoc ยท mime_content_type ยท image_type_to_mime_type ยท image_type_to_extension ยท exif_imagetype ยท array_filter ยท array_map ยท is_callable ยท array_search ยท array_reduce ยท is_scalar ยท localeconv ยท call_user_func_array ยท call_user_method_array ยท array_sum ยท constant ยท is_null ยท pathinfo ยท escapeshellarg ยท is_uploaded_file ยท move_uploaded_file ยท strncasecmp ยท wordwrap ยท php_uname ยท php_sapi_name, (*4)

The emulated functions are of course only ever used, if the current PHP interpreter doesn't provide them itself., (*5)

So the native functions get called as usual on current setups. But your applications are guaranteed to work unchanged for anybody else, regardless of PHP version. Only a minimum compatibility requirement of "PHP 4.1" remains., (*6)

A few classes are also emulated. But it's kind of too much work to port SPL or other extensions over. No contributions so far. And why it never occurred to PHP.net developers to do a reference implementation for anything is somewhat unclear., (*7)

The upgrade.php package also provides multiple emulation include scripts for larger PHP extensions, like gettext, ftp and ctype, mime functions, odbc, dba. See also the Wiki in the Fossil repository., (*8)

Of course, the emulated modules don't behave 100% exactly like the original C implementations - but the upgrade.php extensions work much better than common workaround snippets, and should be 'good enough' for most applications., (*9)

Usage

if (PHP_VERSION < 5.1) { include_once("upgrade.php"); }
json_encode("this will always work now");

Modules in Ext

gettext.php adds _() and various gettext() features. This extension is commonly used for localizing applications. Unlike other methods this is extremely easy to apply in source code., (*10)

ftp.php reimplements FTP access using plain PHP socket functions., (*11)

ctype.php provides a set of character classification functions., (*12)

mime.php has MIME magic filetype detection functions., (*13)

pdo.php is an emulatoion of the PDO database abstraction layer for PHP 4.x and PHP 5.0., (*14)

pspell.php uses the commandline aspell utility to emulate the pspell_*() type of functions for checking for natural language spelling errors., (*15)

bcmath.php for arbitrary precision math functions., (*16)

php40array.php archives the more seldomly used array functions. This has been extracted from the main script, to keep it lean., (*17)

The historic php40.php provides some functions for PHP 4.0 compatibility. Alltough nobody probably still has such old PHP versions running., (*18)

Non Standard

Distributed alongside upgrade.php are a few function collections, which aren't really standard PHP. The author just has been too lazy to instantiat individual project hosting sites., (*19)

http_query.class.php provides HttpRequest funtionality. It is partly compatible to PEAR::HTTPRequest, but mainly in place to later have an emulation for the PHP/PECL http extension and http_* functions., (*20)

input.php is a highly recommended security feature. It wraps the input arrays $_GET, $_POST, $_REQUEST, $_COOKIE, $_SERVER into an object-oriented access layer. This OO access wrapper only allows access to submitted form data and HTTP variables through filter features. In essence this enforces input validation, because raw access is prevented (or at least can be logged)., (*21)

License

Unless noted otherwise, all scripts are Public domain., (*22)

The PDO extension for example, is not., (*23)

The Versions

05/07 2016

dev-master

9999999-dev

Mirror of http://include-once.org/p/upgradephp/

  Sources   Download

public domain

05/07 2016

19.1.1

19.1.1.0

Mirror of http://include-once.org/p/upgradephp/

  Sources   Download

public domain

05/07 2016

19.1

19.1.0.0

Mirror of http://include-once.org/p/upgradephp/

  Sources   Download

public domain