https://github.com/koriym/koriym.datafile
Load XML file with XSD validation
https://github.com/koriym/koriym.datafile
xml xsd
Last synced: 5 months ago
JSON representation
Load XML file with XSD validation
- Host: GitHub
- URL: https://github.com/koriym/koriym.datafile
- Owner: koriym
- License: mit
- Created: 2021-06-13T03:20:44.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-09T05:43:43.000Z (about 2 years ago)
- Last Synced: 2025-09-27T11:36:37.715Z (9 months ago)
- Topics: xml, xsd
- Language: PHP
- Homepage: https://packagist.org/packages/koriym/data-file
- Size: 73.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# Koriym.DataFile
[](https://scrutinizer-ci.com/g/koriym/Koriym.DataFile/?branch=master)
[](https://shepherd.dev/github/bearsunday/BEAR.Package)
[](https://codecov.io/gh/koriym/Koriym.DataFile)
[](https://github.com/koriym/Koriym.DataFile/actions/workflows/continuous-integration.yml)
## XML Config Loader
This library helps you easily validate and load XML configuration files using XSD schemas. It's designed to ensure the integrity and consistency of your configuration data with minimal effort. Additionally, it can be used to load and validate general XML files.
## Installation
To get started, install the required package using Composer:
```bash
composer require koriym/data-file
```
Validate and load the XML file.
## Usage
### Simple XML Load with Validation
Load and validate your XML files with just a few lines of code:
```php
use Koriym\DataFile\XmlLoad;
$xml = (new XmlLoad())('/path/to/xml', '/path/to/xsd');
assert($xml instanceof SimpleXMLElement);
```
### Config XML Load
Easily load configuration files (`config.xml` or `config.xml.dist`) from the specified directory. If both files are present, config.xml is loaded first:
```php
use Koriym\DataFile\XmlConfigLoad;
$xml = (new XmlConfigLoad('confilg.xml'))('/path/to/config_dir', '/path/to/xsd');
assert($xml instanceof SimpleXMLElement);
```
Using `.dist` files allows you to maintain default settings in your repository while keeping local configurations separate.
### Notes
- The XSD schema ensures your XML files adhere to the defined structure and content standards.
- `.dist` files are useful for providing default configurations that can be overridden by local settings.