2017 © Pedro Peláez
 

library loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

image

aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  • Tuesday, January 30, 2018
  • by aklump
  • Repository
  • 1 Watchers
  • 6 Stars
  • 5,738 Installations
  • HTML
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 48 Versions
  • 12 % Grown

The README.md

Loft Data Grids

Packagist link , (*1)

There will be no new features added to this project. I suggest using the Symfony Serializer Component instead for similar functionality. The project will not receive ongoing support., (*2)

Summary

This package is a PHP object-oriented solution for modelling data in two (rows + columns) or three dimensions (rows + columns + pages). It can be thought of like a spreadsheet., (*3)

It allows a single data class ExportData to be used to organize your data in a grid, with various output styles Exporter so you can easily get a .csv file or a .xlsx file, among many others., (*4)

See the code for more documentation., (*5)

Install with Composer

  1. Require this package:, (*6)

    composer require aklump/loft_data_grids:^0.7
    

Usage

Let's build a two-layer data grid. (Layers are called pages.) The first page will contain names and ages of three people. The second page will contain vehicle information. It can be pictured in two tables:, (*7)

Page 0 , (*8)

Name Age
Adam 39
Brandon 37
Charlie 7

Page 1 , (*9)

Color Make
Black Honda
White BMW

In Code

$data_grid = new \AKlump\LoftDataGrids\ExportData();

// By default we're on page 0, row 0.
$data_grid->add('Name', 'Adam')->add('Age', 39)->next();
$data_grid->add('Name', 'Brandon')->add('Age', 37)->next();
$data_grid->add('Name', 'Charlie')->add('Age', 7)->next();

// Switch to page 1; we'll be placed on row 0.
$data_grid->setPage(1);
$data_grid->add('Color', 'Black')->add('Make', 'Honda')->next();
$data_grid->add('Color', 'White')->add('Make', 'BMW')->next();

Accessing data from the object

Think of pointer as a row in a table., (*10)

$value = $data_grid->setPage(0)->setPointer(0)->getValue('Name') // $value === 'Adam'
$value = $data_grid->getValue('Name') // $value === 'Adam'
$value = $data_grid->setPointer(2)->getValue('Name') // $value === 'Charlie'
$value = $data_grid->setPointer(0)->get() // $value === array('Name' => 'Adam', 'Age' => 39)
$value = $data_grid->setPage(1)->setPointer(1)->getValue('Color') // $value === 'White'

Exporting data to other formats

We can export both pages in CSV like this:, (*11)

$exporter = new \AKlump\LoftDataGrids\CSVExporter($data_grid);

$csv_string = $exporter->export();
// "Name","Age"
// "Adam","39"
// "Brandon","37"
// "Charlie","7"

$csv_string = $exporter->export(1);
// "Color","Make"
// "Black","Honda"
// "White","BMW"

Or to get it as JSON..., (*12)

$exporter = new \AKlump\LoftDataGrids\JSONExporter($data_grid);
$json_string = $exporter->export();

(This has been formatted for easier-reading; the actual JSON is minified.), (*13)

[
  [
    {
      "Name": "Adam",
      "Age": 39
    },
    {
      "Name": "Brandon",
      "Age": 37
    },
    {
      "Name": "Charlie",
      "Age": 7
    }
  ],
  [
    {
      "Color": "Black",
      "Make": "Honda"
    },
    {
      "Color": "White",
      "Make": "BMW"
    }
  ]
]

Or any of the other exporter classes., (*14)

Saving to File

$exporter = new \AKlump\LoftDataGrids\XLSXExporter($data_grid, 'users');
$exporter->saveFile();

Exporters: objects as values

  • Exporters can handle objects if they implement the objectHandler method.
  • Exporters can handle \DateTime objects if they set a value for 'dateFormat'.

Testing

  1. Run the PhpUnit tests with ./bin/run_unit_tests.sh

The Versions

30/01 2018

dev-master

9999999-dev http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

30/01 2018

0.4.31

0.4.31.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

27/03 2017

0.4.30

0.4.30.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

27/03 2017

0.4.29

0.4.29.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

26/03 2017

0.4.28

0.4.28.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

22/03 2017

0.4.27

0.4.27.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

20/03 2017

0.4.26

0.4.26.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

17/03 2017

0.4.25

0.4.25.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

18/02 2017

0.4.23

0.4.23.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

17/02 2017

0.4.22

0.4.22.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

17/02 2017

0.4.21

0.4.21.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

17/02 2017

0.4.20

0.4.20.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

17/02 2017

0.4.19

0.4.19.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

16/02 2017

0.4.18

0.4.18.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

01/04 2016

0.4.17

0.4.17.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

29/05 2015

0.4.16

0.4.16.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

07/02 2015

0.4.15

0.4.15.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

07/02 2015

0.4.14

0.4.14.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

23/10 2014

0.4.13

0.4.13.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

23/10 2014

0.4.12

0.4.12.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

23/10 2014

0.4.11

0.4.11.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

23/10 2014

0.4.10

0.4.10.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

03/10 2014

0.4.9

0.4.9.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

06/06 2014

0.4.8

0.4.8.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

03/05 2014

0.4.7

0.4.7.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

23/03 2014

0.4.6

0.4.6.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

26/02 2014

0.4.5

0.4.5.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

23/01 2014

0.4.4

0.4.4.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

18/01 2014

0.4.3

0.4.3.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

18/01 2014

0.4.2

0.4.2.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

18/01 2014

0.4.1

0.4.1.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

18/01 2014

0.4

0.4.0.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

csv excel export spreadsheet

16/12 2013

0.3.4

0.3.4.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

12/09 2013

0.3.3

0.3.3.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

12/09 2013

0.3.2

0.3.2.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

11/09 2013

0.3.1

0.3.1.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

31/08 2013

0.3

0.3.0.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

19/08 2013

0.2.2

0.2.2.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

18/08 2013

0.2.1

0.2.1.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

18/08 2013

0.2

0.2.0.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

02/08 2013

0.1.8

0.1.8.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

02/08 2013

0.1.7

0.1.7.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

02/08 2013

0.1.6

0.1.6.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

01/08 2013

0.1.5

0.1.5.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

01/08 2013

0.1.4

0.1.4.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD-3-Clause

The Requires

 

csv excel export spreadsheet

01/08 2013

0.1.3

0.1.3.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD

csv excel export spreadsheet

01/08 2013

0.1.2

0.1.2.0 http://github.com/aklump/loft_data_grids

PHP Classes to allow data placement in a grid structure and exporting in various data formats.

  Sources   Download

BSD

The Requires

 

csv excel export spreadsheet

14/07 2013

0.1

0.1.0.0

  Sources   Download

The Requires