Download the PHP package halaei/helpers without Composer

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

Miscellaneous Helpers for PHP and Laravel

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

About this Package

This is a collection of miscellanous utilities gathered in one package for you:

Supervisor

Supervisor helps you with running a command in an infinite loop, enabling you to monitor and control it. Supervisor is a generalization of the laravel daemon queue implementation.

To configure the behaviour of supervisor, you can pass an instance of Halaei\Helpers\Supervisor\SupervisorOptions as the second argument to the supervise() method.

Graceful QuitsOnSignals trait.

To gracefully terminate a command on receiving signals, use QuitsOnSignals trait as shown in this example:

Data Object

An instance of DataObject is an object-oriented representation of a key-value array. The constructor of a data object accepts a key-value array and convert its items into types that are defined in the class relations() method. Magic methods are defined to make properties of a data-object accessible via

Data objects are Arrayable, Jsonable, and Rawable, having toArray(), toJson() and toRaw() methods.

Cast model attributes to data objects and collections

To cast model attributes to objects, use HasCastables trait and define the casts via static $castables like the way relations are defined in DataObject classes. This trait is designed for document-oriented databases like mongodb - works great with jenssegers/laravel-mongodb package. To work with SQL databases, $casts attributes should also be used to handle json encoding/decoding.

Eloquent Cache

The EloquentCache class is a key-value repository for your eloquent models with caching features. If you want to cache your models using this repository, you may optionally let your model implement the Cacheable interface. The implementation of Cacheable is also available via CacheableTrait. Features include:

  1. Caching find by id queries via EloquentCache::find() method.
  2. Caching find by secondary key queries via EloquentCache::findBySecondaryKey() method.
  3. Invalidating the cache for a specific model via EloquentCache::invalidateCache, so that other processes don't use cache for that model.
  4. Cleaning the cache when updating and deleting the model via EloquentCache::update() and EloquentCache::delete() methods.

Eloquent Batch Update & Insert Ignore

When performance does matter, it is important to update multiple rows of a table at once using a single update query. To do so, use the Collection::update macro:

The resulting SQL statement (assuming that the old value for sensor#12 is 32):

To enable batch update feature (+ insert ignore) register \Halaei\Helpers\Eloquent\EloquentServiceProvider::class in the list of providers in config/app.php.

Redis-Based blocking mutual exclusive lock

The \Halaei\Helpers\Redis\Lock class provides Redis-Based mutual exclusive locks with auto-release timer. The implementation is based on rpoplpush and brpoplpush Redis commands.

A process that requires a lock should call the lock($name, $tr = 2) method in a loop until it returns true; where $name is the name of the lock and $tr is the auto-release timer in seconds (with milliseconds resolution). If the lock is on-hold, the lock method waits for at most $tr seconds, until the lock is released.

When a process is done it must immediately release the lock by calling the unlock($name) method, with the same $name parameter used for calling the lock method. If the process holds a lock for more that $tr seconds, it will be regarded as a failed process and the lock will be automatically released.

Note: Callers to the lock may not be aware of the release of the lock, if the lock was auto-released after the call to the lock method. So they should call lock once more.

Process

The Halaei\Helpers\Process\Process class is a simplified version of Symfony\Process that fixes an infinite loop issue. (Note: It wasn't easy for me to deliver my fix to Symfony and guarantee it won't break something else, so I fix the issue in this package.) To summarize the bug, if the process doesn't read all the input, Symfony\Process might fall into an infinite loop and never find out that the process is not running anymore.

Currently, Halaei\Helpers\Process doesn't have all the features of Symfony\Process. So in case you don't pass a large input to your process, or you are sure your process never terminates without reading the whole input, and if you want features like reading the process output while the process is running, feel safe to use Symfony\Process instead.

You can create an instance of Halaei\Helpers\Process just like the way you create Symfony\Process\Process. To run a process, you may call $process->run() which always return an instance of Halaei\Helpers\Process\ProcessResult after the process exits, or call $process->mustRun() which only returns ProcessResult only if the process exits with zero, but in case of timeout or non-zero exit code or failure in starting the process it throws a Halaei\Helpers\Process\ProcessException exception.

Future plans

Running concurrent processes (async).

Clean-up DB transactions between handling queued jobs

In order to make sure there is nothing wrong with the default DB connection even after a messed-up handling of a queued job, call Halaei\Helpers\Listeners\RefreshDBConnections::boot() in AppServiceProvider::boot() function.

Safely terminate long-running workers

Long-running workers may cause unexpected issues if you are not 100% careful. To safely terminate long-running workers call Halaei\Helpers\Listeners\RandomWorkerTerminator::boot() in AppServiceProvider::boot().

Disabling blade @parent

@parent feature of Laravel framework is implemented with a minor security bug. So you may need to disable the feature. If in your config/app.php file relplace \Illuminate\View\ViewServiceProvider::class with \Halaei\Helpers\View\ViewServiceProvider::class.

Number Encryption

If you need to obfuscate auto-increment numbers into random-looking strings, use the Numcrypt class:

The NumCrypt constructor accepts charset for the accepted characters in the output and a key for encryption (uxing XOR). By default, the charset is [a-z0-9], and the key is 308312529.

Note: NumCrypt is not meant to be cryptographically secure.

License

This package is open-sourced software licensed under the MIT license


All versions of helpers with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4.0
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 halaei/helpers contains the following files

Loading the files please wait ....