laradic/support

Laravel support package

2.5.0 2022-06-19 08:12 UTC

README

License

A general support package for the Laravel 5 framework. Laradic Support provides flexible and reusable components of code for commonly used functionality as well as the means to customize the default Laravel 5 folder structure.

The package follows the FIG standards PSR-1, PSR-2, and PSR-4 to ensure a high level of interoperability between shared PHP code.

Overview

  • Over 100 mixins for Str, Arr and Collection. Enable/disable each one using the configuration file.
  • Bench for simple benchmarking
  • Dot is the dot-notated equivalent of Collection
  • FS as a singleton Filesystem with static callable methods
  • Sorter for dependency sorting
  • CommandsVisibility trait for your Console\Kernel to hide commands/namespaces (also adds -A|--show-all option)
  • And more...

Quick Installation

Begin by installing the package through Composer.

composer require laradic/support=~2.0

Documentation

Classes

  • Bench for simple benchmarking
  • Dot is the dot-notated equivalent of Collection
  • FS as a singleton Filesystem with static callable methods
  • Sorter for dependency sorting
  • CommandsVisibility trait for your Console\Kernel to hide commands/namespaces (also adds -A|--show-all option)

Helpers

path
echo path_join('/var/www/vhost', '..', 'myhost', 'config.ini');
// => /var/www/myhost/config.ini

echo path_get_directory('/var/www/vhost/laradic/config.ini');
// => vhost

echo path_canonicalize('/var/www/vhost/laradic/../config.ini');
// => /var/www/vhost/config.ini
// => C:/Programs/config.ini

echo path_make_absolute('config/config.yml', '/var/www/project');
// => /var/www/project/config/config.yml

echo path_make_relative('/var/www/project/config/config.yml', '/var/www/project/uploads');
// => ../config/config.yml

$paths = array(
    '/var/www/vhosts/project/httpdocs/config/config.yml',
    '/var/www/vhosts/project/httpdocs/images/banana.gif',
    '/var/www/vhosts/project/httpdocs/uploads/../images/nicer-banana.gif',
);
path_get_longest_common_base_path($paths);
// => /var/www/vhosts/project/httpdocs

path_get_filename('/views/index.html.twig');
// => index.html.twig

path_get_filename_without_extension('/views/index.html.twig');
// => index.html

path_get_filename_without_extension('/views/index.html.twig', '.html.twig');
// => index

path_get_extension('/views/index.html.twig');
// => twig

path_has_extension('/views/index.html.twig');
// => true

path_has_extension('/views/index.html.twig', 'twig');
// => true

path_has_extension('/images/profile.jpg', array('jpg', 'png', 'gif'));
// => true

path_change_extension('/images/profile.jpeg', 'jpg');
// => /images/profile.jpg

path_get_home_directory();

Mixins

Filesystem
Collection
Arr
ByteUnits
Str