https://github.com/markcell/salvaon
Package for Laravel based on Eloquent to manage XML files.
https://github.com/markcell/salvaon
laravel php xml
Last synced: 7 months ago
JSON representation
Package for Laravel based on Eloquent to manage XML files.
- Host: GitHub
- URL: https://github.com/markcell/salvaon
- Owner: markcell
- License: mit
- Created: 2014-09-25T11:46:13.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-05-18T19:23:00.000Z (about 5 years ago)
- Last Synced: 2025-08-21T11:56:36.432Z (10 months ago)
- Topics: laravel, php, xml
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 5
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Salvaon
[](https://packagist.org/packages/markcell/salvaon) [](https://packagist.org/packages/markcell/salvaon) [](https://packagist.org/packages/markcell/salvaon) [](https://packagist.org/packages/markcell/salvaon)
Package for Laravel based on Eloquent to manage XML files with SimpleXMLElement and xpath.
> [!WARNING]
> This repository hasn't been actively maintained for quite some time. The code is still here if you find it useful, but no further updates or support will be provided.
## Usage
Install the package through Composer.
```js
{
"require": {
"laravel/framework": "4.2.*",
"markcell/salvaon": "dev-master" // or "markcell/salvaon": "1.0.*"
}
}
```
Edit 'app/config/app.php', and add a new item to the 'aliases' array:
```php
'Salvaon' => 'Markcell\Salvaon\Salvaon'
```
Publish configuration file from package:
```bash
php artisan config:publish markcell/salvaon
```
You may now edit these options at 'app/config/packages/markcell/salvaon/config.php'. Or copy this file to 'app/config' folder with name 'salvaon.php'.
Now, your XML models can simply extend 'Salvaon':
```php
count();
// Get child from XML by $primaryKey or fail if not exists.
Breakfast::findOrFail('French Toast');
// Get child from XML with where condition.
$food = Breakfast::select()->where('name', '=', 'French Toast')->get();
// Update fields from selected child $food.
$food->price = '3.25€';
$food->calories = 450;
// Save changes.
$food->save();
// Create new XML child.
$new = new Breakfast;
// Add data to child fields.
$new->name = 'French Toast';
$new->price = '4.50€';
$new->description = 'Thick slices made from our homemade sourdough bread';
$new->calories = 600;
// Save new child to XML file with tag attributes.
$new->save(array('id' => 26092014));
```
## License
Licensed under the MIT license.