An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# Salvaon
[![Latest Stable Version](https://poser.pugx.org/markcell/salvaon/v/stable.svg)](https://packagist.org/packages/markcell/salvaon) [![Total Downloads](https://poser.pugx.org/markcell/salvaon/downloads.svg)](https://packagist.org/packages/markcell/salvaon) [![Latest Unstable Version](https://poser.pugx.org/markcell/salvaon/v/unstable.svg)](https://packagist.org/packages/markcell/salvaon) [![License](https://poser.pugx.org/markcell/salvaon/license.svg)](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.