2017 © Pedro Peláez
 

library salvaon

Package for Laravel based on Eloquent to manage XML files.

image

markcell/salvaon

Package for Laravel based on Eloquent to manage XML files.

  • Thursday, February 5, 2015
  • by markcell
  • Repository
  • 5 Watchers
  • 5 Stars
  • 201 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 7 % Grown

The README.md

Salvaon

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

Package for Laravel based on Eloquent to manage XML files with SimpleXMLElement and xpath., (*2)

Usage

Install the package through Composer., (*3)

{
    "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:, (*4)

'Salvaon' => 'Markcell\Salvaon\Salvaon'

Publish configuration file from package:, (*5)

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'., (*6)

Now, your XML models can simply extend 'Salvaon':, (*7)

<?php

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';

}

See example of 'breakfast.xml' file on this link: https://github.com/markcell/salvaon/blob/master/breakfast.xml, (*8)

Examples

// 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));

License

Licensed under the MIT license., (*9)

The Versions

05/02 2015

dev-master

9999999-dev

Package for Laravel based on Eloquent to manage XML files.

  Sources   Download

MIT

The Requires

 

laravel xml eloquent xpath

21/10 2014

v1.0.6

1.0.6.0

Package for Laravel based on Eloquent to manage XML files.

  Sources   Download

MIT

The Requires

 

laravel xml eloquent xpath

21/10 2014

v1.0.5

1.0.5.0

Package for Laravel based on Eloquent to manage XML files.

  Sources   Download

MIT

The Requires

 

laravel xml eloquent xpath

06/10 2014

v1.0.4

1.0.4.0

Package for Laravel based on Eloquent to manage XML files.

  Sources   Download

MIT

The Requires

 

laravel xml eloquent xpath

03/10 2014

v1.0.3

1.0.3.0

Package for Laravel based on Eloquent to manage XML files.

  Sources   Download

MIT

The Requires

 

laravel xml eloquent xpath

30/09 2014

v1.0.2

1.0.2.0

Package for Laravel based on Eloquent to manage XML files.

  Sources   Download

MIT

The Requires

 

laravel xml eloquent xpath

30/09 2014

v1.0.1

1.0.1.0

Package for Laravel based on Eloquent to manage XML files.

  Sources   Download

MIT

The Requires

 

laravel xml eloquent xpath

27/09 2014

v1.0.0

1.0.0.0

Package for Laravel based on Eloquent to manage XML files.

  Sources   Download

MIT

The Requires

 

laravel xml eloquent xpath