Download the PHP package dbeurive/util without Composer

On this page you can find all versions of the php package dbeurive/util. 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 util

Description

This package implements some basic, but frequently used, utilities.

Installation

From the command line:

composer require dbeurive/util

From your composer.json file:

{
    "require": {
        "dbeurive/util": "*"
    }
}

API documentation

The detailed documentation of the API can be extracted from the code by using PhpDocumentor. The file phpdoc.xml contains the required configuration for PhpDocumentor. To generate the API documentation, just move into the root directory of this package and run PhpDocumentor from this location.

Note:

Since all the PHP code is documented using PhpDoc annotations, you should be able to exploit the auto completion feature from your favourite IDE. If you are using Eclipse, NetBeans or PhPStorm, you probably won’t need to consult the generated API documentation.

Quick overview

Please, refer to the API (that you can generate), or to the code itself for details.

Arrays

Function Description
array_keys_exists(array $inKeys, array $inArray) Test if a given array contains a given list of keys.
array_keep_keys(array $inKeysToKeep, array $inArray, $inOptValuesOnly=false) Extract a specified set of keys/values - or values only - from a given associative array.

Classes

Function Description
implements_interface($inClassName, $inInterfaceName) Test if a given class implements a given interface.
implements_interfaces($inClassName, array $inInterfaceNames) Tests if a given class implements a given list of interfaces.
get_namespace($inPath) Get the namespace for a given PHP file.

Data

Function Description
to_callable_php_file($inData, $inOptFilePath=false) Return a string that represents the PHP code that, if executed, returns a given PHP data.

Examples

String

Function Description
trim($inString, $inWhere=UtilString::TRIM_END) Remove spaces or carriage returns from a given string.
text_linearize($inString, $inOptShrinkSpaces=false, $inOptTrimEnd=false) This method takes a string that possibly spans over several lines and transforms it so it spans over one line only.

Code

Function Description
require_with_args($inPath, array $inArgs) Loads and executes a given PHP file, just like the function require(), except that it allows the caller to pass parameters to the code being executed.

Examples

SQL

MySql

Function Description
quoteFieldName($inFieldName) Quote a field's name.
quoteFieldsNames(array $inFieldsNames, $inOptTableName=null, $inOptDatabaseName=null) Quote, and optionally, fully qualify, an array of fields' names.
qualifyFieldName($inFieldName, $inTableName, $inBaseName=null) Qualify a given field's name relatively to a given table's name, and, optionally, a given database name.
qualifyFieldsNames(array $inFieldsNames, $inTableName, $inOptDatabaseName=null) Qualify a given list of fields' names relatively to a given table's name, and, optionally, a given database name.
developSql($inSqlTemplate, array $inSchema, $inOptAs=false, $inOptQuote=false, array $inTags=[]) "Develop" a SQL request. The term "develop" means "replace an expression like 'user.*' into a list of fields in SELECT statements". Please see the explanation below.

Examples

Explanation for method developSql()

First, let's consider these 3 examples:

Example 1:: The SQL "template" below:

SELECT user.* FROM `user`

Can be developed into one of these expressions:

SELECT user.id, user.login FROM `user`
SELECT user.id AS 'user.id', user.login AS 'user.login' FROM `user`
SELECT `user`.`id` AS 'user.id', `user`.`login` AS 'user.login' FROM `user`

Example 2:: The SQL "template" below:

SELECT user.*, profile.* FROM `user` INNER JOIN `profile` ON user.id=profile.fk_user_id

Can be developed into one of these expressions:

SELECT user.id, user.login, profile.id, profile.age, profile.fk_user_id FROM `user` INNER JOIN `profile` ON user.id=profile.fk_user_id
SELECT user.id AS 'user.id', user.login AS 'user.login', profile.id AS 'profile.id', profile.age AS 'profile.age', profile.fk_user_id AS 'profile.fk_user_id' FROM `user` INNER JOIN `profile` ON user.id=profile.fk_user_id
SELECT `user`.`id` AS 'user.id', `user`.`login` AS 'user.login', `profile`.`id` AS 'profile.id', `profile`.`age` AS 'profile.age', `profile`.`fk_user_id` AS 'profile.fk_user_id' FROM `user` INNER JOIN `profile` ON user.id=profile.fk_user_id

Example 3:: And the (silly) SQL "template" below:

SELECT __USER__ FROM `user` WHERE user.login='user.*'

Can be developed into one of these expressions:

SELECT user.id, user.login FROM `user` WHERE user.login='user.*'
SELECT user.id AS 'user.id', user.login AS 'user.login' FROM `user` WHERE user.login='user.*'
SELECT `user`.`id` AS 'user.id', `user`.`login` AS 'user.login' FROM `user` WHERE user.login='user.*'

For example 1

$template = "SELECT user.* FROM `user`";
$schema   = [ 'user' => ['id', 'login'], 'profile' => ['id', 'age', 'fk_user_id'] ];

$result = UtilMySql::developSql($template, $schema, false, false); // => SELECT user.id, user.login FROM `user`
$result = UtilMySql::developSql($template, $schema, true, false);  // => SELECT user.id AS 'user.id', user.login AS 'user.login' FROM `user`
$result = UtilMySql::developSql($template, $schema, true, true);   // => SELECT `user`.`id` AS 'user.id', `user`.`login` AS 'user.login' FROM `user`

For example 2

$template = "SELECT user.*, profile.* FROM `user` INNER JOIN `profile` ON user.id=profile.fk_user_id";
$schema = [ 'user' => ['id', 'login'], 'profile' => ['id', 'age', 'fk_user_id'] ];

$result = UtilMySql::developSql($template, $schema, false, false); // => SELECT user.id, user.login, profile.id, profile.age, profile.fk_user_id FROM `user` INNER JOIN `profile` ON user.id=profile.fk_user_id
$result = UtilMySql::developSql($template, $schema, true, false);  // => SELECT user.id AS 'user.id', user.login AS 'user.login', profile.id AS 'profile.id', profile.age AS 'profile.age', profile.fk_user_id AS 'profile.fk_user_id' FROM `user` INNER JOIN `profile` ON user.id=profile.fk_user_id
$result = UtilMySql::developSql($template, $schema, true, true);   // => SELECT `user`.`id` AS 'user.id', `user`.`login` AS 'user.login', `profile`.`id` AS 'profile.id', `profile`.`age` AS 'profile.age', `profile`.`fk_user_id` AS 'profile.fk_user_id' FROM `user` INNER JOIN `profile` ON user.id=profile.fk_user_id

For example 3

$template = "SELECT __USER__ FROM `user` WHERE user.login='user.*'";
$schema   = [ 'user' => ['id', 'login'], 'profile' => ['id', 'age', 'fk_user_id'] ];
$tags     = ['__USER__' => 'user.*'];

$result = UtilMySql::developSql($template, $schema, false, false, $tags); // => SELECT user.id, user.login FROM `user`
$result = UtilMySql::developSql($template, $schema, true, false, $tags);  // => SELECT user.id AS 'user.id', user.login AS 'user.login' FROM `user`
$result = UtilMySql::developSql($template, $schema, true, true, $tags);   // => SELECT `user`.`id` AS 'user.id', `user`.`login` AS 'user.login' FROM `user`

Unit tests

Function Description
call_private_or_protected_static_method($inClassName, $inMethodName) Execute a private or a protected static method from a given class.
call_private_or_protected_method($inClassName, $inMethodName, $inObject) Execute a private or a protected non-static method from a given class, within the context of a given object.

Examples

Binary tools

TODO

Debug

TODO

Examples

The unit tests are good examples.


All versions of util with dependencies

PHP Build Version
Package Version
No informations.
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 dbeurive/util contains the following files

Loading the files please wait ....