Download the PHP package torugo/util without Composer

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

PHP Utility library

Library with useful classes and methods.

Table of Contents

Requirements

Installation

On terminal type:

Or add to your require list on composer.json file:

Utilities

CDT (Compressed Date and Time)

CDT is a way of storing date and time including milliseconds.

get

Returns a CDT from current date/time.

fromTimestamp

Generates a CDT from a timestamp or microtime.

fromDateTime

Generates a CDT from a PHP DateTime object.

toMicrotime

Converts a CDT to a microtime (float) number.

toDateTime

Converts a CDT to a PHP DateTime object.


DateWriter

Transforms DateTime objects to written date/time.

Format options

Accepts all PHP DateTimeInterface::format characters.

Everything in brackets ([]) will not change in any way.

By default, all names of months and days of the week are defined as title case, to transform the cases use the markings:

Internationalization

Languages available to write the names of months and days of the week.

Option Language Examples
'de' Deutsch "Januar" ... "Dezember" / "Montag" ... "Sonntag"
'en' English "January" ... "December" / "sunday" ... "saturday"
'es' Spanish "Enero" ... "Diciembre" / "Domingo" ... "Sábado"
'fr' French "Janvier" ... "Décembre" / "Dimanche" ... "Samedi"
'pt' Portuguese "Janeiro" ... "Dezembro" / "Domingo" ... "Sábado"

Usage


SemVer

Validates and compare semantic version numbers. The version number must follow semver.org rules

Usage


TBase64 (url safe)

Encodes and decodes strings to Base64 that can be used on URLs.

Usage


TEncrypt

Encrypts/Decrypts strings using symmetric keys.

[!NOTE] Symmetric key:
Means that the key used for encryption must be the same for decryption.
Each cipher algorithm has a minimum key length in bytes, check the table bellow.

Usage

Cipher algorithm

Use the TCipher enum to set a new cipher algorithm.

Setting the cipher algorithm:

List of all supported cipher algorithms, default is AES_256_CFB.

Algorithm Min key length in bytes
AES_128_CBC 16
AES_128_CFB 16
AES_128_CFB1 16
AES_128_CFB8 16
AES_128_CTR 16
AES_128_OFB 16
AES_128_WRAP_PAD 16
AES_192_CBC 24
AES_192_CFB 24
AES_192_CFB1 24
AES_192_CFB8 24
AES_192_CTR 24
AES_192_OFB 24
AES_192_WRAP_PAD 24
AES_256_CBC 32
AES_256_CFB 32
AES_256_CFB1 32
AES_256_CFB8 32
AES_256_CTR 32
AES_256_OFB 32
AES_256_WRAP_PAD 32
ARIA_128_CBC 16
ARIA_128_CFB 16
ARIA_128_CFB1 16
ARIA_128_CFB8 16
ARIA_128_CTR 16
ARIA_128_OFB 16
ARIA_192_CBC 24
ARIA_192_CFB 24
ARIA_192_CFB1 24
ARIA_192_CFB8 24
ARIA_192_CTR 24
ARIA_192_OFB 24
ARIA_256_CBC 32
ARIA_256_CFB 32
ARIA_256_CFB1 32
ARIA_256_CFB8 32
ARIA_256_CTR 32
ARIA_256_OFB 32
CAMELLIA_128_CBC 16
CAMELLIA_128_CFB 16
CAMELLIA_128_CFB1 16
CAMELLIA_128_CFB8 16
CAMELLIA_128_CTR 16
CAMELLIA_128_OFB 16
CAMELLIA_192_CBC 24
CAMELLIA_192_CFB 24
CAMELLIA_192_CFB1 24
CAMELLIA_192_CFB8 24
CAMELLIA_192_CTR 24
CAMELLIA_192_OFB 24
CAMELLIA_256_CBC 32
CAMELLIA_256_CFB 32
CAMELLIA_256_CFB1 32
CAMELLIA_256_CFB8 32
CAMELLIA_256_CTR 32
CAMELLIA_256_OFB 32
CHACHA20 32
DES_EDE_CBC 16
DES_EDE_CFB 16
DES_EDE3_CFB 24
DES_EDE3_CFB1 24
DES_EDE3_CFB8 24
DES_EDE3_OFB 24
SM4_CBC 16
SM4_CFB 16
SM4_CTR 16
SM4_OFB 16

TFile

Manipulates text files parsing its content.

Check if file exists

The static method exists returns if a file exists in a given path, you can use the argument createIfNotExists to create a file if it not exist.

Create a file

The static method create tries to create a file on a given path.
Returns true on success or false if not.

Checking if a file is writable

Load file lines

Returns the lines of a text file as an array

Parsing .env files

Parses the content of an env file as an associative array.

Parsing .json files

Loads a JSON file content and returns it as an associative array.
In case of invalidation returns an empty array.

Parsing .key files

Loads a .key file content and returns the key from it.

The key file, is a text file that contains a key splitted in lines.
The key MUST be surrounded by -----BEGIN----- and -----END-----.

.key file example


TPass

Generates random passwords, and checks password strength

Options

Option Type Default Description
includeLowercase bool true Include lowercased letters
includeUppercase bool true Include uppercased letters
includeNumbers bool true Include numeric characters
includeSymbols bool true Include special characters
beginWithALetter bool false Password should begin with a letter

[!NOTE] When enabling beginWithALetter assure that includeLowercase or includeUppercase is enabled.

Setting symbols source

The default symbols source is !;#$%&()*+,-./:;<=>?@[]^_{|}~;

To set a custom symbols source, use the method setSymbols.

Checking password strength

To check the password strength use the method checkPasswordStrength;

It returns an int value from 0 to 4, where:

Examples


TUID (Torugo Unique ID)

Generates a randomic unique ID with date and time.

This tool can generate three types of IDs:

Type Length Sample
Short 20 QJLM77R-TS0SHULDI0SH
Medium 26 KMSEEBAN-NC7V-TM0SHULDI0U2
Long 36 PVA4M433-20L5-K1HVUPLQW-TL0SHULDI0VT

Generating

Validating

Getting Date and Time


TRandom

Generates random strings and numbers

Random strings

Sets the source chars used to generate random strings.

Parameters

Parameter Type Default Description
alpha string a...zA...Z Alphabetical characters used to generate strings.
numbers string 0123456789 Numerical characters used to generate strings.
symbols string !;#%&()*+,-./:;<=>?@[]^_{|}~ Special characters used to generate strings.
includeAlpha bool true Should include alphabetical chars.
includeNumbers bool true Should include numbers.
includeSymbols bool true Should include symbols.
startWithAlphaChar bool false Should start with alphabetical characters.

Setting the source characters

Random Numbers

Generates a random integer between the given range.

Random Numbers with leading zeros

Generates a positive random integer with leading zeros.


Traits

Empty Values Trait

Returns an empty value for a specific type.

From Array Factory

Instantiates a class from a key=>value array.

  1. The keys must be equal to the properties names.
  2. All properties must be setted as public.

Example

Contribute

It is currently not open to contributions, I intend to make it available as soon as possible.

License

This library is licensed under the MIT License - see the LICENSE file for details.


All versions of util with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-mbstring Version *
ext-openssl Version *
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 torugo/util contains the following files

Loading the files please wait ....