Download the PHP package andrey-helldar/pretty-array without Composer
On this page you can find all versions of the php package andrey-helldar/pretty-array. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andrey-helldar/pretty-array
More information about andrey-helldar/pretty-array
Files in andrey-helldar/pretty-array
Package pretty-array
Short Description Simple conversion of an array to a pretty view
License MIT
Informations about the package pretty-array
Pretty Array
Simple conversion of an array to a pretty view.
Installation
To get the latest version of Pretty Array
package, simply require the project using Composer:
Instead, you may of course manually update your require
block and run composer update
if you so choose:
Introduction
Q: Why did you create this package when there is a cooler symfony/var-exporter?
The big minus of package symfony/var-exporter is that it works differently with numeric keys.
For example, we have an array:
When exporting through it, the file will contain the following content:
Q: Why do you think this is bad?
This package has a framework-independent base. However, it was originally developed as an assistant for the Laravel Lang: HTTP Statuses package.
This package allows you to publish language translations of the HTTP Status Codes for the Laravel and Lumen frameworks.
A feature of the framework is that IDEs that help with development do not know how to read the numeric keys of arrays of translation files, so it was necessary to translate theminto a text equivalent.
This behavior includes http-statuses.php file:
The peculiarity of the package is that it takes the values of the source file and combines it with what is already in the application. Thus, the output is a file with numeric keys that IDE helpers cannot read:
Using
Source array for all examples:
Saving numeric keys without alignment
Result:
Saving string keys without alignment
Result:
Saving numeric keys with alignment
Result:
Saving string keys with alignment
Result:
Saving simple array
Result:
Change key case
Result:
The following options are available:
- camelCase (
DragonCode\Contracts\Pretty\Arr\Caseable::CAMEL_CASE
); - kebab-case (
DragonCode\Contracts\Pretty\Arr\Caseable::KEBAB_CASE
); - PascalCase (
DragonCode\Contracts\Pretty\Arr\Caseable::PASCAL_CASE
); - snake_case (
DragonCode\Contracts\Pretty\Arr\Caseable::SNAKE_CASE
); - no case (
DragonCode\Contracts\Pretty\Arr\Caseable::NO_CASE
). By default;
NO_CASE
means that key register processing will not be performed.
Storing file
Result in stored file foo.php
:
As JSON
Result in stored file foo.json
:
License
This package is licensed under the MIT License.
All versions of pretty-array with dependencies
ext-dom Version *
ext-mbstring Version *
dragon-code/contracts Version ^2.20
dragon-code/support Version ^6.11.2