Download the PHP package / without Composer

On this page you can find all versions of the php package /. 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?
/
Rate from 1 - 5
Rated 5.00 based on 2 reviews

Informations about the package

Jasny's PHP functions

Build Status Code Coverage Scrutinizer Code Quality SensioLabsInsight Packagist Stable Version Packagist License

A set PHP functions that should have been part of PHP's core libraries.

Example

But wait, there's more...

If you like these functions, you'll love the Improved PHP library. Go and check it out.

Installation

composer require jasny\php-functions

Usage

All functions are in the Jasny namespace.

To import all the functions to the global namespace require 'global.php' anywhere in your application.

Alternatively, add it to the autoload section of composer.json.

Type functions

is_associative_array

boolean is_associative_array(mixed $var)

Check if variable is an associative array.

is_numeric_array

boolean is_numeric_array(mixed $var)

Check if variable is a numeric array.

is_stringable

boolean is_stringable(mixed $var)

Check if variable can be cast to a string. Returns true for all scalar values except booleans and objects that have a __toString method.

objectify

stdClass|mixed objectify(array|mixed $var)

Turn an associated array into a stdClass object recursively.

arrayify

array|mixed arrayify(stdClass|mixed $var)

Turn an stdClass object into an associated array recursively.

get_type_description

string get_type_description(mixed $var)

Get the type of a variable in a descriptive way. E.g. "stream resource" and "DateTime object".

expect_type

expect_type(mixed $var, string|string[] $type, string $throwable = null, string $message = null)

Validate that an argument has a specific type.

As type you can specify any internal type, including callable and object, a class name or a resource type (eg stream resource). Typed arrays are not supported.

By default a TypeError (PHP 7) is thrown. You can specify a class name for any Throwable class. For PHP 5 you must specify the class name.

The message may contain a %s, which is replaced by the type of $var.

Example

Array functions

array_only

array array_only(array $array, array $keys)

Return an array with only the specified keys.

array_without

array array_without(array $array, array $keys)

Return an array without the specified keys.

array_contains_all

boolean array_contains_all(array $array, array $subset, boolean $strict = false)

Check if an array contains all values in a set.

This function works as expected with nested arrays or an array with objects.

array_contains_all_assoc

boolean array_contains_all_assoc(array $array, array $subset, boolean $strict = false)

Check if an array contains all values in a set with index check.

This function works as expected with nested arrays or an array with objects.

array_contains_any

boolean array_contains_any(array $array, array $subset, boolean $strict = false)

Check if an array contains any value in a set.

This function works as expected with nested arrays or an array with objects.

array_contains_any_assoc

boolean array_contains_any_assoc(array $array, array $subset, boolean $strict = false)

Check if an array contains any value in a set with index check.

This function works as expected with nested arrays or an array with objects.

array_find

mixed array_find(array $array, callable $callback, int $flag = 0)

Find an element of an array using a callback function. Returns the value or FALSE if no element was found.

Flag determining what arguments are sent to callback:

array_find_key

string|int|false array_find_key(array $array, callable $callback, int $flag = 0)

Find a key of an array using a callback function. Returns the key or FALSE if no element was found.

array_flatten

array function array_flatten(string $glue, array $array)

Flatten a nested associative array, concatenating the keys.

Example

Will become

array_join_pretty

string array_join_pretty(string $glue, string $and, array $array);

Join an array, using the 'and' parameter as glue the last two items.

Example

String functions

str_starts_with

boolean str_starts_with(string $string, $string $substr)

Check if a string starts with a substring.

str_ends_with

boolean str_ends_with(string $string, string $substr)

Check if a string ends with a substring.

str_contains

boolean str_contains(string $string, string $substr)

Check if a string contains a substring.

str_before

string str_before(string $string, string $substr)

Get a string before the first occurence of the substring. If the substring is not found, the whole string is returned.

str_after

string str_after(string $string, string $substr)

Get a string after the first occurence of the substring. If the substring is not found, an empty string is returned.

str_remove_accents

string str_remove_accents(string $string)

Replace characters with accents with normal characters.

str_slug

string str_slug(string $string, string $glue = '-')

Generate a URL friendly slug from the given string.

Cast functions

camelcase

string camelcase(string $string)

Turn a sentence, StudlyCase, snake_case or kabab-case into camelCase.

studlycase

string studlycase(string $string, $ucfirst = true)

Turn a sentence, camelCase, snake_case or kabab-case into StudlyCase.

snakecase

string snakecase(string $string)

Turn a sentence, StudlyCase, camelCase or kabab-case into snake_case.

kababcase

string kababcase(string $string)

Turn a sentence, StudlyCase, camelCase or snake_case into kabab-case.

uncase

string uncase(string $string)

Turn StudlyCase, camelCase, snake_case or kabab-case into a sentence.

Server functions

ip_in_cidr

boolean ip_in_cidr(string $ip, string $cidr)

Check if an IP address is in a CIDR block.

Works with IPv4 and IPv6.

ipv4_in_cidr

boolean ipv4_in_cidr(string $ip, string $cidr)

Check if an IPv4 address is in a CIDR block.

ipv6_in_cidr

boolean ipv6_in_cidr(string $ip, string $cidr)

Check if an IPv6 address is in a CIDR block.

inet_to_bits

string inet_to_bits(string $inet)

Converts inet_pton output to string with bits.

File functions

file_contains

boolean file_contains(string $filename, string $string)

Check if a string is present in the contents of a file.

This function is memory usage friendly by not loading the whole contents of the file at once.

fnmatch_extended

boolean fnmatch_extended(string $pattern, string $path)

Match path against wildcard pattern. This is an extended version of fnmatch.

Function handling functions

call_user_func_assoc

mixed call_user_func_assoc(callable $callback, array $param_arr)

Call a callback with named parameters as associative array.

Object functions

object_get_properties

array object_get_properties(object $object, bool $dynamic = true)

Get the public properties of an object.

Unlike get_object_vars, this method will return only public properties regardless of the scope.

The dynamic flag controls if the output should be filtered, so only properties defined in the class are set.

object_set_properties

array object_get_properties(object $object, array $data, bool $dynamic = true)

Set the public properties of an object.

The dynamic flag controls if $data should be filtered, so only properties defined in the class are set.


All versions of with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
ramsey/array_column Version ^1.1
mikey179/vfsstream Version ^1.5
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 / contains the following files

Loading the files please wait ....