Download the PHP package improved/improved without Composer
On this page you can find all versions of the php package improved/improved. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package improved
Playground for developing consistent and modern functions for PHP that are safe to use.
Most libraries here are in permanent beta, though some might become production ready. Any library written in PHP can be used, but is mostly intended as proof of concept.
If you choose to use these libraries, please provide feedback either through via github issues or via Twitter @ArnoldDaniels.
Why?
The core libraries of PHP are a mess. Functions have inconsistent names, inconsistent arguments, inconsistent and sometimes dangerouds return values and deal with errors poorly. This functions have been created decades ago and no longer live up to current day standards.
While there are many functions, a lot are redundant, while others are missing. For example;
- There are many array functions, but these won't work with other iterables like
ArrayObject
. - For trimming a string there is
trim
,rtrim
andltrim
. For padding a string there is onlystr_pad
, which takes aSTR_PAD_RIGHT
,STR_PAD_LEFT
orSTR_PAD_BOTH
as argument. - For missing functions there are standard patterns to make it work. For instance, to find out if a string contains a
specific substring we use
strpos($string, $substring) !== false
. - etc
This make it unnecessarily difficult for non-PHP developers to read PHP code and creates a barrier for newcomers to an otherwise beginner-friendly language.
What?
All functions are consistently named and take the subject as first argument. The library reduces the number of functions, opting for the use of constants for options. Options are always the last argument.
The functions throw an Exception in case of an error and return only sensible data.
The library contains of the following packages:
- iterable - Like array functions, for any iterable. Uses Generators.
- functions - Function handling and functional programming.
- type - Type checking and casting.
Roadmap
- string - String manipulation.
- array - Limited set of functions that don't make sense for other iterables.
For more high level functionality like database access, filesystem access, image processing, etc, it's recommended to use an OOP abstraction layer. This is outside of the scope of the improved PHP library.
How?
All modules code as extension or composer package. The extension is not yet available. The compatibility library can be installed via
composer install improved/improved
All functions are in the Improved
namespace, rather than importing them one by one, it's recommended to alias the
namespace to i
.
All versions of improved with dependencies
improved/iterable Version ~0.1.0
improved/function Version ~0.1.0
improved/type Version ~0.1.0