skprods/laravel-helpers

This package is abandoned and no longer maintained. The author suggests using the skprods/advanced-laravel package instead.

Helpers for Laravel framework

2.0.2 2022-05-23 16:16 UTC

This package is auto-updated.

Last update: 2022-05-26 17:25:53 UTC


README

Warning

This package will no longer be supported. You can find the current version here: https://github.com/skprods/advanced-laravel

Installation:

composer require skprods/laravel-helpers ^2.0

After installation, connect the provider to your application.

Laravel

In config/app.php:

'providers' => [
    ...,
    SKprods\LaravelHelpers\Providers\HelpersServiceProvider::class,
]

Lumen

In bootstrap/app.php:

$app->register(SKprods\LaravelHelpers\Providers\HelpersServiceProvider::class);

Console

Console is a facade for displaying information to the terminal. It can be used to display the script execution process.

For example:

use SKprods\LaravelHelpers\Facades\Console;

Console::info('Hello from terminal!');

The output differs in color depending on the type.

Filesystem

Expanding interaction with the file system. You can use it to copy a file or directory to a new path.

use SKprods\LaravelHelpers\Filesystem;

$destinationPath = "/new/path/";

$sourceFile = "/path/to/file.jpg";
Filesystem::copyFile($sourceFile, $destinationPath);
// File will be accessible by the path /new/path/file.jpg

$sourceDir = "/path/to/dir";
Filesystem::copyDirectory($sourceDir, $destinationPath);
// All files of the original directory will be saved to
// the new directory. For example, /path/to/dir/file.jpg
// will be accessible by the path /new/path/file.jpg

Path

Converter for path string. It converts the path according to certain rules:

  • the path does not start with "/"
  • the path to the directory ends with "/"

For example:

use SKprods\LaravelHelpers\Path;

$path = "/some/directory/and/some/file.jpg";
Path::prepareFile($path); // some/directory/and/some/file.jpg

$path = "/some/directory/path";
Path::prepareDirectory($path) // some/directory/path/