Download the PHP package simp/php-toolkit without Composer

On this page you can find all versions of the php package simp/php-toolkit. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-toolkit

php-toolkit

Fluent, dependency-free PHP helpers for strings, numbers, arrays/iterables, phone numbers, emails and countries — with Phone and Country backed by real ISO-3166 + international dialing-code data (bundled in resources/countries.json, merged from your two uploaded datasets, 249 countries / 237 with dial codes).

⚠️ One naming note

You asked for new String("..."). PHP doesn't allow that — string (like int, float, bool, array, null, void, object, mixed, never) is a reserved word and PHP raises a fatal error if you try to declare a class called String or Array. So this library calls them Str and Arr instead, but everything else works exactly as you described:

Install

No Composer registry access needed — drop the folder in and require the autoloader:

Or, if you do have Composer/Packagist access, composer.json is already set up with PSR-4 (Toolkit\ → src/), so composer dump-autoload + require 'vendor/autoload.php' works too.

Requires PHP ≥ 8.1 with the mbstring extension (intl optional, used for better transliteration in Str::ascii() if present, with an iconv fallback otherwise).

Run the tests / demo


Str — string manipulation

Every method returns a new Str (immutable, chainable). Cast to string with (string), echo, or ->value().

Grouped by category:

Category Methods
Case upper lower ucfirst lcfirst title pascal/studly camel snake kebab slug swapCase
Trim/pad trim ltrim rtrim squish pad padLeft padRight
Search/replace substr limit words reverse repeat replace replaceFirst replaceLast remove append prepend between before beforeLast after afterLast mask wrap unwrap
Checks isEmpty isNotEmpty contains containsAll startsWith endsWith equals is (wildcard) isAscii isAlpha isAlphaNumeric isNumeric isJson isUuid isUrl isEmail
Convert toInt toFloat toBool split chunk toArray jsonDecode stripTags escape unescape ascii
Info length wordCount countOccurrences
Static Str::random(len) Str::uuid4()

Arr — array manipulation

A fluent, chainable wrapper around PHP arrays (think a dependency-free Laravel Collection). Implements ArrayAccess, Countable, IteratorAggregate and JsonSerializable, so an Arr works with foreach, count(), $arr[0], and json_encode() directly. Transformation methods are immutable — they return a new Arr rather than mutating in place.

Dot-notation for nested data:

Full method list, grouped:

Category Methods
Access get set has forget (dot-notation aware) · first last only except pluck
Transform map flatMap mapWithKeys filter reject reduce each keys values flip flatten collapse chunk split combine
Combine merge mergeRecursive union diff diffKeys intersect intersectKeys unique
Order sort sortBy sortByDesc sortKeys sortKeysDesc reverse shuffle random
Mutate-ish (return new Arr) pad prepend push pop shift
Group groupBy countBy partition
Aggregate count sum avg min max isEmpty isNotEmpty contains containsKey search implode
Convert toArray toJson lazy() (→ LazyCollection)
Static Arr::create Arr::of Arr::wrap Arr::range Arr::materialize

Arr also accepts a Traversable/generator in its constructor and eagerly materializes it — great for arrays and small-to-medium query results. For huge or infinite sequences, use LazyCollection instead.


LazyCollection — memory-safe iterables

A generator-backed pipeline for large, expensive, or literally infinite iterables (file lines, DB cursors, ranges). Nothing runs until you call a terminal method (each, first, reduce, count, toArray, sum) — and operations like take()/takeWhile() let you short-circuit a source that never ends on its own.

Reading a large file lazily, line by line:

Kind Methods
Lazy (no work until consumed) map filter reject take takeWhile skip chunk tap keys values
Terminal (consumes the pipeline) each first reduce sum contains count toArray toArr() (→ Arr)
Static LazyCollection::make($arrayOrGeneratorFn) LazyCollection::range($start, $end = null, $step = 1) LazyCollection::repeat($value, $times = null)

Passing a fn(): iterable factory closure (rather than an already-created Generator) to make() is what lets a LazyCollection be safely iterated more than once — plain arrays work either way.


Num — number manipulation

Full list: format currency percentage ordinal roman toWords humanFileSize add subtract multiply divide abs round ceil floor clamp percentageOf isEven isOdd isPositive isNegative isZero isBetween isPrime, and statics random sum average min max range.


Country — ISO 3166 + dialing data

Resolves by alpha-2, alpha-3, numeric ISO code, or name — whichever you pass in.

Unknown identifiers throw Toolkit\Exceptions\UnknownCountryException; use Country::tryFind() if you'd rather get null.


Phone — phone numbers (powered by Country)

North American numbers format NANP-style automatically:

Honest limitation on isMobile(): the source dataset only has country-level dialing codes, not the detailed number-range tables carriers publish, so true mobile-vs-landline detection isn't reliably derivable from it. isMobile() returns null (unknown) unless you register prefixes yourself:

Invalid/unparseable numbers throw Toolkit\Exceptions\InvalidPhoneNumberException.


Email — validation & formatting

Register more free/disposable domains at runtime:

Email::fromValidated($addr) throws Toolkit\Exceptions\InvalidEmailException if the address is malformed; the plain constructor never throws (call isValid() yourself).


Data & attribution

resources/countries.json was built by merging your two uploaded files:

236 of 272 Wikipedia entries matched a real ISO country (the rest are things like satellite services, disputed territories, or sub-national exchanges that have no ISO code, e.g. Kosovo, Taiwan, Transnistria — they're simply not in your countries.json source). 237 of 249 ISO countries ended up with a dial code attached.

Project layout


All versions of php-toolkit with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package simp/php-toolkit contains the following files

Loading the files please wait ...