1. Go to this page and download the library: Download markcell/salvaon library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
markcell / salvaon example snippets
'Salvaon' => 'Markcell\Salvaon\Salvaon'
class Breakfast extends Salvaon {
/**
* The file associated with the model
*
* @var string
*/
protected $file = 'breakfast.xml';
/**
* Root element of the document
*
* @var string
*/
protected $root = 'breakfast';
/**
* Child elements of the root
*
* @var string
*/
protected $child = 'food';
/**
* The primary key for the model
*
* @var string
*/
protected $primaryKey = 'name';
}
// Get all child nodes from XML root.
$foods = Breakfast::all();
// Count elements from selected childs $foods.
$foods->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));
bash
php artisan config:publish markcell/salvaon
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.