Download the PHP package technicalguru/utils without Composer

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

php-utils

This is a collection of useful classes and functions for every day PHP life. It includes things such as:

These classes are no rocket science, just simple helpers that prevent from wiriting the same code in various flavours over and over again.

License

This project is licensed under GNU LGPL 3.0.

Installation

By Composer

By Package Download

You can download the source code packages from GitHub Release Page

Classes

Request class

The Request class extracts many useful information from the current HTTP request. It provides:

It is possible to create an object yourself, but it is recommend to use the singleton:

Inspect the source code to find out about the various methods available.

Date class

The date class handles issues for localization, timezones and conversion into different formats or creation from various formats. Here are some examples:

Inspect the source code to find out about the various methods available.

Logging

Logging is very simple. Set your log level (if not INFO) and start logging:

The Log can also help when you need to debug something:

The __FILE__ parameter will oppress the current file from appearing in the stacktrace. You can easily use the function without this argument to have the current file included:

Finally, you can create your special instances of a log for some modules and log from there, e.g.

User Notifications

Sometimes it is hard to display success or error messages because the message needs to be displayed in another script, another HTTP call or even just later. The following snippet will remember the message across multiple call within a session.

The registartion will not only remember the message but also print the message into the error log when it's an instance of Debug, Error, Warning or Info.

In another call or script you can retrieve your messages again to display:

Authentication Helper

A simple authentication helper interface along with a default implementation is provided:

Sensitive Data Obfuscation

Publishing sensitive data such as e-mail addresses and phone numbers is dangerous nowadays as spammers grab such information automatically from websites. The utils package provides a javascript-based way to obfuscate this information on websites. Its' idea is based on the rot13 obfuscation method but uses a random character mapping instead of a fixed rotation. This idea was chosen because rot13 seems to be a kind of standard in obfuscation and spammers might already be able to read them.

It shall be noted that it is still not impossible to read the information even when obfuscated. But it requires a bit more sophisticated effort (Javascript execution) to gain the sensitive information.

Idea: The text to be obfuscated is replaced - char by char - by other characters from a map. This map is generated uniquely for this special obfuscation instance. Other obfuscations on the same page will use different maps. The HTML source displays only: [javascript protected]. However, a special javascript will run after the page loaded and replace exactly this text with the real content.

Two obfuscation methods exists: a simple text obfuscation and an e-mail obfuscation which also creates a mailto: link that the user can click.

Here is how you use it:

Please notice that not all characters are supported in the default character map. It covers mainly e-mail addresses and phone numbers. However, you can pass your own character set to the obfuscate methods as third argument. Please consult the source code for more details.

Text Templating

To ease the generation of dynamic texts, a template processor is provided. This processor can work on texts that contain variables in curly brackets {{variable-definition}}. The processor knows objects, snippets and formatters.

Objects are application objects that hold attributes that you want to be replaced. An object's attribute will be referenced in a template with {{objectKey.attributeName}}, e.g. {{user.name}}.

Snippets are more complex replacements that will be inserted in your template. This is useful when you need the same complex text structure in multiple template generations, e.g. for a footer or a header text. Snippets are referenced in a template by their keys only: {{snippetKey}}. A snippet is implemented by the interface Snippet. A snippet can take parameters as {{snippetKey:param1:param2...}}.

Formatters can be used to format an object's attribute. Formatters can take parameters to further customize the formatting. A good example is the DateFormatter. The formatter is referenced with the object's attribute by {{objectKey.attribute:formatterKey:param1:param2...}}, e.g. {{user.created_on:date:rfc822}}.

All three elements - objects, snippets and formatters - are given to the Processor in its constructor:

The language is for information and can be used in snippets or formatters to select the right text.

Finally you can process a template:

Other Utils

There are some daily tasks that need to be done in applications. The Utils class addresses a few of them:

Inspect the source code to find more about the methods available.

Contribution

Report a bug, request an enhancement or pull request at the GitHub Issue Tracker.


All versions of utils with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
ext-mbstring Version *
technicalguru/i18n Version ~1
ezyang/htmlpurifier Version ^4
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 technicalguru/utils contains the following files

Loading the files please wait ....