buymeua/parser
最新稳定版本:v1.0.11
Composer 安装命令:
composer require buymeua/parser
包简介
Help with parse tests/files with products
README 文档
README
This package can parse files with any format with custom adapters for example we have two adapters for xml and yml files!
Installation
- Package requires php-xmlrpc and php-mbstring (but need check before install maybe you have this packages on the your server)
sudo apt-get install php-xmlrpc php-mbstring
- You can install this package via composer using this command:
composer require buymeua/parser
-
The package will automatically register itself.
-
You can publish the configs file using the following command:
php artisan vendor:publish --provider="Buyme\Parser\BuymeParserServiceProvider" --tag=buyme-parser-config
This will create the package's config file called buyme_parser.php in the config directory. These are the contents of the published config file:
return [ /* |------------------------------------------------------------------------------------------------------------ | The package will use this mapping_parser for detect what adapter need connect to parse file by extension. |------------------------------------------------------------------------------------------------------------ */ "adapters" => [ 'xml' => \Buyme\Parser\Adapter\SimpleXML::class, 'yml' => \Buyme\Parser\Adapter\XMLReader::class, ], ];
- You can publish the lang file using the following command:
php artisan vendor:publish --provider="Buyme\Parser\BuymeParserServiceProvider" --tag=buyme-parser-lang
How to use
-
After setting up the config file values you are all set to use the following methods:
-
First you need to initialize an instance of the BuymeParser.php class using Facade or direct connection of the BuymeParser class:
Facade
use Buyme\Parser\Facades\BuymeParser;
Direct
use Buyme\Parser\BuymeParser;
Use Container
$byml = app(BuymeParser::class);
OR Use ID
public function __construct(private BuymeParser $buymeParser) { }
By URL
$this->buymeParser->open('https://example.com/file.yml');
By Local Path
$this->buymeParser->open('storage/xml/file.yml');
$categories = $this->buymeParser->getCategories(); $currencies = $this->buymeParser->getCurrencies(); $products = $this->buymeParser->getProducts();
Testing
You can run the tests with:
vendor/bin/phpunit
License
The MIT License (MIT). Please see the License File for more information.
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-02