Данная библиотека несет цель упростить жизнь php разработчику и сократить время на решение рутинных задач.

Related tags

Laravel helpers
Overview

Полезные вспомогательные функции для php разработчика

PHP-CI Source Code GitHub tag (latest SemVer) Packagist

Установка

composer require mellanyx/helpers

Обёртка над функцией print_r - p()

<?php
$arr = ['one', 'two', 'bar' => ['aaa' => 'str_aaa', 'bbb' => 'str_bbb']];

p($arr);

Результат:
<pre>
Array
(
    [0] => 'one'
    [1] => 'two'
    ['bar'] => [
        ['aaa'] => 'str_aaa'
        ['bbb'] => 'str_bbb'
    ]

)
</pre>

Записывает массив в файл - l()

<?php

$arr = ['one', 'two', 'bar' => ['aaa' => 'str_aaa', 'bbb' => 'str_bbb']];

l($arr);

Склонение существительных после числительных - numWord()

<?php
use Mellanyx\Helpers\Utils;

Utils::numWord(5, ['товар', 'товара', 'товаров']);

Результат: 5 товаров

Utils::numWord(5, ['товар', 'товара', 'товаров'], false);

Результат: товаров

Перевод bytes to KB/MB/GB/TB - numWord()

<?php
use Mellanyx\Helpers\Utils;

Utils::formatSize(1024);

Результат: 1.00 KB

Генератор html ссылки - anchor()

<?php
use Mellanyx\Helpers\Utils;

$extras = ['#test_id','.test_class','_blank'];
Utils::anchor('https://google.com', 'Проверка связи', 'Это Title', $extras);

Результат: <a href="https://google.com" title="Это Title" id="test_id" class="test_class" target="_blank">Проверка связи</a>

Проверка массива на ассоциативность - isAssoc()

<?php
use Mellanyx\Helpers\Arr;

$arr = ['one', 'two', 'bar' => ['aaa' => 'str_aaa', 'bbb' => 'str_bbb']];
Arr::isAssoc($arr);

Результат: 1

Конвертирует массив в объект - toObject()

<?php
use Mellanyx\Helpers\Arr;

$arr = ['one', 'two', 'bar' => ['aaa' => 'str_aaa', 'bbb' => 'str_bbb']];
Arr::toObject($arr);

Результат:
stdClass Object
(
    [0] => one
    [1] => two
    [bar] => stdClass Object
        (
            [aaa] => str_aaa
            [bbb] => str_bbb
        )

)

Возвращает первый элемент массива - arrayFirst()

<?php
use Mellanyx\Helpers\Arr;

$arr = ['one', 'two', 'bar' => ['aaa' => 'str_aaa', 'bbb' => 'str_bbb']];
Arr::arrayFirst($arr);

Результат: one

Возвращает последний элемент массива - arrayLast()

<?php
use Mellanyx\Helpers\Arr;

$arr = ['one', 'two', 'bar' => ['aaa' => 'str_aaa', 'bbb' => 'str_bbb']];
Arr::arrayLast($arr);

Результат:
Array
(
    [aaa] => str_aaa
    [bbb] => str_bbb
)

Получает значение в массиве по точечной нотации для ключей - arrayGet()

<?php
use Mellanyx\Helpers\Arr;

$arr = ['one', 'two', 'bar' => ['aaa' => 'str_aaa', 'bbb' => 'str_bbb']];
Arr::arrayGet('bar.aaa', $arr);

Результат: str_aaa

Устанавливает значение в массиве с использованием точечной записи - arraySet()

<?php
use Mellanyx\Helpers\Arr;

$arr = ['one', 'two', 'bar' => ['aaa' => 'str_aaa', 'bbb' => 'str_bbb']];
Arr::arraySet('bar.zzz', 'added from func', $arr)

Результат:
Array
(
    [0] => one
    [1] => two
    [bar] => Array
        (
            [aaa] => str_aaa
            [bbb] => str_bbb
            [zzz] => added from func
        )

)

Вставляет одну или несколько строк в другую строку в определенной позиции - strInsert()

<?php
use Mellanyx\Helpers\Str;

$keyValue = [
    ':color' => 'brown',
    ':animal' => 'dog'
];

$string = 'The quick :color fox jumps over the lazy :animal.';

Str::strInsert($keyValue, $string);

Результат: The quick brown fox jumps over the lazy dog.

Ограничение строки по количеству слов - limitWords()

<?php
use Mellanyx\Helpers\Str;

$string = 'The quick brown fox jumps over the lazy dog';

Str::limitWords($string, 3);

Результат: The quick brown...

Ограничение строки по количеству символов - limit()

<?php
use Mellanyx\Helpers\Str;

$string = 'The quick brown fox jumps over the lazy dog';

Str::limit($string, 15);

Результат: The quick brown...

License

Данная mellanyx/helpers библиотека лицензирована для использования в рамках MIT License (MIT).
Пожалуйста прочитайте LICENSE для большей информации.

You might also like...
PHP package to help the development of Laravel-based Telegram bots
PHP package to help the development of Laravel-based Telegram bots

Laravel-telegram-bot Project description goes here. This description is usually two to three lines long. It should give an overview of what the projec

Deploy and execute non-PHP AWS Lambda functions from your Laravel application.

Sidecar for Laravel Deploy and execute non-PHP AWS Lambda functions from your Laravel application. Read the full docs at hammerstone.dev/sidecar/docs.

Laravel blade directives and php helpers for serverside rendered content, based on browser window size WITHOUT css

Laravel Window Size and Breakpoints Laravel blade directives and php helpers for server side rendered content, based on browser window size WITHOUT cs

Send PHP errors to Flare
Send PHP errors to Flare

Send PHP errors to Flare This repository contains a PHP client to send PHP errors to Flare. Documentation You can find the documentation of this packa

Winbox.js wrapper in PHP.
Winbox.js wrapper in PHP.

Winbox PHP A wrapper for using Winbox.js just coding in PHP. Based on: JS Repo - https://github.com/nextapps-de/winbox Installation Clone the repo or

Control frontend access to properties/methods in Livewire using PHP 8 attributes.
Control frontend access to properties/methods in Livewire using PHP 8 attributes.

This package adds PHP 8.0 attribute support to Livewire. In specific, the attributes are used for flagging component properties and methods as frontend-accessible.

Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Boilerplate code for protecting a form with proof of work. Uses javascript in the browser to generate the hashcash and PHP on the server to generate the puzzle and validate the proof of work.

Evo is a Laravel package that leverages PHP 8 features.

Evo is a Laravel package that leverages PHP 8 features. It change the way you write Laravel app into something like this: #[RoutePrefix('users')] clas

PHP client library for reCAPTCHA, a free service to protect your website from spam and abuse.

reCAPTCHA PHP client library reCAPTCHA is a free CAPTCHA service that protects websites from spam and abuse. This is a PHP library that wraps up the s

Releases(v2.0.4)
  • v2.0.4(Jan 16, 2022)

  • 2.0.2(Dec 30, 2021)

    Функции p() и l() были вынесены в файл fastFunctions, для того что бы их можно было быстро вызывать не используя namespace.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Dec 29, 2021)

    Данная библиотека несет цель упростить жизнь php разработчику и сократить время на решение рутинных задач.

    Source code(tar.gz)
    Source code(zip)
Public API for the project coding.events. Made in PHP 8.0 with Lumen 8, PHP-FPM, NGINX and MySQL 8.

coding.events API Uma API feita apenas para passar o tempo, montando uma API para o site <coding.events>. Sinta-se livre para usar esse código como es

Kaique Garcia 3 Oct 9, 2022
PHP phonebook with map (Active Directory, LDAP -> MySQL, PHP)

LDAP phonebook ???? ???? Development ветка Вопросы предпочтительнее задавать в Issues, а не по почте Корпоративный телефонный справочник с отображение

null 47 Nov 30, 2022
States allows you to create PHP classes following the State Pattern in PHP.

States allows you to create PHP classes following the State Pattern in PHP. This can be a cleaner way for an object to change its behavior at runtime without resorting to large monolithic conditional statements and this improve maintainability and workflows writing.

Teknoo Software 10 Nov 20, 2022
PHP components - collection of cross-project PHP classes

PHP components Collection of cross-project PHP classes. Install: $ composer require ansas/php-component Ansas\Component\Convert\ConvertPrice Convert "

null 1 Jan 5, 2022
Lavacharts is a graphing / charting library for PHP 5.4+ that wraps Google's Javascript Chart API.

Lavacharts 3.1.12 Lavacharts is a graphing / chart library for PHP5.4+ that wraps the Google Chart API. Stable: Dev: Developer Note Please don't be di

Kevin Hill 616 Dec 17, 2022
PHP Secure Headers

Secure Headers Add security related headers to HTTP response. The package includes Service Providers for easy Laravel integration. Version Installatio

null 431 Dec 26, 2022
A Simple GUID creator Laravel Package for PHP

A Simple GUID creator package for PHP. This package is useful for creating globally unique identifiers (GUID). It's under MIT license so it's free for

Sujip Thapa 15 Jun 26, 2021
laravel package for the Ar-PHP Project

laravel package for the Ar-PHP Project this is just a wrapper to use with laravel for the Ar-PHP Library, for more details checkout khaled-alshamaa

ATM-code 20 Dec 21, 2022
A laravel service provider for the netsuite-php library service

netsuite-laravel A PHP supplemental package to the ryanwinchester/netsuite-php package to add the NetSuite service client to the service container of

NetsuitePHP 6 Nov 9, 2022
Simplest Slugify for PHP to convert string into a slug.

Simplest Slugify for PHP to convert string into a slug. Documentation You can find the detailed documentation here in Slugify Documentation. Contribut

Pharaonic 6 Mar 12, 2022