diff --git a/README.md b/README.md index 8912f95..5325a2b 100644 --- a/README.md +++ b/README.md @@ -2,21 +2,18 @@ [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jupitern/table/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/jupitern/table/?branch=master) [![Latest Stable Version](https://poser.pugx.org/jupitern/table/v/stable.svg)](https://packagist.org/packages/jupitern/table) [![Latest Unstable Version](https://poser.pugx.org/jupitern/table/v/unstable.svg)](https://packagist.org/packages/jupitern/table) [![License](https://poser.pugx.org/jupitern/table/license.svg)](https://packagist.org/packages/jupitern/table) # jupitern/table -#### PHP table generation. +#### HTML table generation with PHP. Pass your data using: * JSON, Arrays (associative or not). * result set using PDO or you favourite framework ORM. * directly or using ajax requests. - -Give some power to you tables with your preferred js library: -* Datatables (tested with v1.10.4). +* Integrates easily with your preferred js library. * more to come... -* easily extensible to add your custom plugin render ## Demo: -[demo here](http://nunochaves.com/dev/table/examples) +soon... ## Requirements @@ -24,18 +21,18 @@ PHP 5.4 or higher. ## Installation -Include jupitern/datatables in your project, by adding it to your composer.json file. +Include jupitern/table in your project, by adding it to your composer.json file. ```javascript { "require": { - "jupitern/table": "0.*" + "jupitern/table": "1.*" } } ``` ## Usage ```php -// instance Datatables with instance name +// instance Table with instance name \Jupitern\Table\Table::instance('dt_example') // set data for non ajax requests @@ -52,6 +49,7 @@ Include jupitern/datatables in your project, by adding it to your composer.json ->setData($data) // add attributes to the
->add()
-// add datatables plugin with some params to your table
-// to get some paging ordering and filtering to work
-->plugin('Datatables')
- // add this param to grab your data from ajax request
- // this option sets several datatable params at once behind the scenes
- ->ajax('http://localhost/getRemoteData.php')
- // add param disable ordering on actions column
- // any datatables params can be added using this function
- ->param('columnDefs', '[{ "targets": 3, "orderable": false }]')
-->add()
-
// echo table output
->render();
@@ -153,6 +140,7 @@ $filterData = $db->query("SELECT name as val, name FROM persons limit 10")->fetc
\Jupitern\Table\Table::instance('dt_example')
->setData($data)
+ ->attr('id', 'demoTable')
->attr('class', 'table table-bordered table-striped table-hover')
->attr('cellspacing', '0')
->attr('width', '100%')
@@ -185,35 +173,28 @@ $filterData = $db->query("SELECT name as val, name FROM persons limit 10")->fetc
})
->css('width', '10%')
->add()
- ->plugin('Datatables')
- ->param('columnDefs', '[{ "targets": 3, "orderable": false }]')
- ->add()
->render();
?>
-Jquery, Datatables should be included. Bootstrap is optional
+Jquery and Datatables should be included.
-
+
-
-
-
-
+
+
-
-
-
-
-
+
+
+
+
```
## Roadmap
- - [ ] more js table plugins
- - [ ] more examples (including ajax data)
+ - [ ] add demo and more examples
- [ ] code some tests
## Contributing
diff --git a/composer.json b/composer.json
index 971fdc5..160643b 100644
--- a/composer.json
+++ b/composer.json
@@ -16,7 +16,7 @@
"issues": "https://github.com/jupitern/table/issues"
},
"require" :{
- "php":">=5.3"
+ "php":">=5.4"
},
"autoload": {
"psr-4": {
diff --git a/examples/arrayAssoc.php b/examples/arrayAssoc.php
deleted file mode 100644
index ea337b1..0000000
--- a/examples/arrayAssoc.php
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
-
-
-
-
-
-
- Associtive array example:-
-
-
- setData([
- ['id' => 1, 'country' => 'Afghanistan', 'country_code' => 'AF', 'phone_code' => '96'],
- ['id' => 2, 'country' => 'Porugal', 'country_code' => 'PT', 'phone_code' => '351'],
- ])
- ->attr('class', 'table table-bordered table-striped table-hover')
- ->attr('cellspacing', '0')
- ->attr('width', '100%')
- ->column()
- ->title('Country')
- ->value('country')
- ->attr('data-val', 'foo')
- ->css('width', '50%')
- ->css('background-color', '#efefef')
- ->css('background-color', '#f5f5f5', true)
- ->add()
- ->column()
- ->title('Country Code')
- ->value('country_code')
- ->css('color', '#778899')
- ->css('width', '20%')
- ->add()
- ->column()
- ->title('Phone Code')
- ->value('phone_code')
- ->css('color', '#DEB887')
- ->css('width', '20%')
- ->add()
- ->column()
- ->value(function ($row) {
- return 'edit';
- })
- ->css('width', '10%')
- ->add()
- ->render();
- }
- catch (\Exception $e) {
- echo 'Error: ' . $e->getMessage();
- }
- ?>
-
-
-
-
- |