Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

skprods/laravel-helpers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Helpers for Laravel framework

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/