Package Data | |
---|---|
Maintainer Username: | AXP |
Maintainer Contact: | axp-dev@yandex.com (Alexander Pushkarev) |
Package Create Date: | 2017-07-20 |
Package Last Update: | 2023-05-28 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-16 15:03:07 |
Package Statistics | |
---|---|
Total Downloads: | 10,461 |
Monthly Downloads: | 666 |
Daily Downloads: | 37 |
Total Stars: | 5 |
Total Watchers: | 2 |
Total Forks: | 4 |
Total Open Issues: | 1 |
File Parser Library for PHP. List of formats: json, xml, query string, serialize, ini, csv.
$ composer require axp-dev/file-parser
Add service provider within app/config/app.php
:
'providers' => [
...
AXP\FileParser\FileParserServiceProvider::class
]
Add a facade alias:
'aliases' => [
...
'FileParser' => AXP\FileParser\Facades\FileParser::class
]
Add service provider within bootstrap/app.php
:
$app->register('AXP\FileParser\FileParserServiceProvider');
Add a facade alias:
class_alias('AXP\FileParser\Facades\FileParser', 'FileParser');
FileParser::json($string) : array
$string = '{"id":1,"name":"A green door","price":12.5,"tags":["home","green"]}';
$data = FileParser::json($string);
print_r($data);
FileParser::xml($string) : array
$string = '<?xml version="1.0" encoding="UTF-8" ?>
<card>
<id>1</id>
<name>A green door</name>
<price>12.5</price>
<tags>home</tags>
<tags>green</tags>
</card>';
$data = FileParser::xml($string);
print_r($data);
FileParser::queryString($string) : array
$string = 'id=1&name=A+green+door&price=12.5&tags%5B0%5D=home&tags%5B1%5D=green';
$data = FileParser::queryString($string);
print_r($data);
FileParser::serialize($string) : array
$string = 'a:4:{s:2:"id";s:1:"1";s:4:"name";s:12:"A green door";s:5:"price";s:4:"12.5";s:4:"tags";a:2:{i:0;s:4:"home";i:1;s:5:"green";}}';
$data = FileParser::serialize($string);
print_r($data);
FileParser::ini($string) : array
$string = '[card]
id = 1
name = "A green door"
price = 12.5
tags[] = home
tags[] = green';
$data = FileParser::ini($string);
print_r($data);
FileParser::csv($string, $delimiter = ';') : array
$string = 'Title1;Title2;Title3
one;two;three
example1;example2;example3';
$data = FileParser::csv($string);
print_r($data);
FileParser::yaml($string) : array
$string = 'latitude: 52.7157856867271
longitude: -8.8741735070805
zoom: 15';
$data = FileParser::yaml($file);
print_r($data);
Alexander Pushkarev, e-mail: axp-dev@yandex.com
Open-sourced software licensed under the MIT license