-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dcba29d
Showing
24 changed files
with
2,285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/.github/ export-ignore | ||
/build/ export-ignore | ||
/tests/ export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/phive.xml export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: verify project | ||
|
||
on: | ||
push: | ||
branches: [ trunk ] | ||
pull_request: | ||
branches: [ trunk ] | ||
|
||
jobs: | ||
install: | ||
|
||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Validate composer.json and composer.lock | ||
run: composer validate | ||
|
||
- name: Cache Composer packages | ||
id: composer-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor | ||
key: composer-lock-${{ hashFiles('**/composer.lock') }} | ||
|
||
- name: Install composer dependencies | ||
if: steps.composer-cache.outputs.cache-hit != 'true' | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Cache phive packages | ||
id: phive-tools-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: tools | ||
key: phive-tools-${{ hashFiles('**/phive.xml') }} | ||
|
||
- name: Install phive tools | ||
if: steps.phive-tools-cache.outputs.cache-hit != 'true' | ||
run: wget -O phive https://phar.io/releases/phive.phar && chmod +x phive && ./phive install --trust-gpg-keys 4AA394086372C20A,12CE0F1D262429A5,31C7E470E2138192 && chmod -R +x ./tools/ | ||
|
||
- name: 'Tar project' | ||
run: tar -cf project.tar . | ||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: installed-project | ||
path: project.tar | ||
|
||
phplint: | ||
needs: install | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: installed-project | ||
|
||
- name: Untar project. | ||
run: tar -xf project.tar | ||
|
||
- name: Run php lint | ||
run: find ./src/ ./tests/ -type f -name '*.php' -print0 | xargs -0 -n1 -P4 php -l -n | (! grep -v "No syntax errors detected" ) | ||
|
||
phpcs: | ||
needs: phplint | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: installed-project | ||
|
||
- name: Untar project. | ||
run: tar -xf project.tar | ||
|
||
- name: Run phpcs | ||
run: ./tools/phpcs --standard=PSR12 --extensions=php ./src/ ./tests/ | ||
|
||
test: | ||
needs: phplint | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: installed-project | ||
|
||
- name: Untar project. | ||
run: tar -xf project.tar | ||
|
||
- name: Run PHPUnit test | ||
run: ./tools/phpunit -c ./build/phpunit.xml | ||
|
||
static-analysis: | ||
needs: phplint | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: installed-project | ||
|
||
- name: Untar project. | ||
run: tar -xf project.tar | ||
|
||
- name: Run Psalm | ||
run: cd build/ && ../tools/psalm --shepherd --no-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/build/cache/ | ||
/build/phpunit/ | ||
/tools/ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Cyril VERLOOP | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# DataTables | ||
|
||
Simple PHP classes to map DataTables Request and Reponse requiring PHP 7.4+. | ||
|
||
[](https://github.com/cyrilverloop/datatables/blob/trunk/LICENSE) | ||
[](https://shepherd.dev/github/cyrilverloop/datatables) | ||
[](https://www.php.net/) | ||
|
||
|
||
## Installation | ||
|
||
### As a Composer depedency | ||
|
||
In your project directory run | ||
```shellsession | ||
user@host project$ composer require "cyril-verloop/datatables" | ||
``` | ||
|
||
### For development purposes | ||
|
||
```shellsession | ||
user@host ~$ cd [PATH_WHERE_TO_PUT_THE_PROJECT] # E.g. ~/projects/ | ||
user@host projects$ git clone https://github.com/cyrilverloop/datatables.git | ||
user@host projects$ cd datatables | ||
user@host datatables$ composer install -o | ||
user@host datatables$ phive install | ||
``` | ||
|
||
|
||
## Usage | ||
|
||
You can put the elements requested by DataTables into a "Request" object. | ||
|
||
```php | ||
use CyrilVerloop\Datatables\Request; | ||
|
||
$request = new Request( | ||
$columns, | ||
$order, | ||
$start, | ||
$length, | ||
$search | ||
); | ||
``` | ||
|
||
Then use the "getCriterias" and "getOrderBy" methods to get parameters for a database query. | ||
|
||
```php | ||
$criterias = $request->getCriterias(); | ||
$orderBy = $request->getOrderBy(); | ||
``` | ||
|
||
Once you have the requested records from the database, you can put them into a "Response" object | ||
and send the object back to the browser thanks to the "jsonSerialize" method. | ||
|
||
```php | ||
use CyrilVerloop\Datatables\Response; | ||
|
||
$response = new Response($draw, $data, $recordsTotal, $recordsFiltered); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" | ||
bootstrap="../vendor/autoload.php" | ||
cacheResultFile="./cache/.phpunit.result.cache" | ||
forceCoversAnnotation="true" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
verbose="true" | ||
colors="true" | ||
> | ||
<coverage processUncoveredFiles="true"> | ||
<include> | ||
<directory suffix=".php">../src</directory> | ||
</include> | ||
|
||
<report> | ||
<clover outputFile="phpunit/clover.xml" /> | ||
<crap4j outputFile="phpunit/crap4j.xml" /> | ||
<html outputDirectory="phpunit/html" lowUpperBound="35" highLowerBound="70" /> | ||
<xml outputDirectory="phpunit/xml" /> | ||
</report> | ||
</coverage> | ||
|
||
<testsuites> | ||
<testsuite name="Project Test Suite"> | ||
<directory>../tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<logging> | ||
<junit outputFile="phpunit/junit.xml" /> | ||
<testdoxHtml outputFile="phpunit/testdox.html" /> | ||
</logging> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<psalm | ||
autoloader="../vendor/autoload.php" | ||
errorLevel="1" | ||
resolveFromConfigFile="true" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="https://getpsalm.org/schema/config" | ||
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
> | ||
<projectFiles> | ||
<directory name="../src/" /> | ||
<ignoreFiles> | ||
<directory name="../vendor/" /> | ||
</ignoreFiles> | ||
</projectFiles> | ||
</psalm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "cyril-verloop/datatables", | ||
"description": "A library to use DataTables with PHP 7.4+.", | ||
"type": "library", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"CyrilVerloop\\Datatables\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"CyrilVerloop\\Datatables\\Tests\\": "tests/" | ||
} | ||
}, | ||
"require": { | ||
"php": ">=7.4", | ||
"cyril-verloop/iterator": "^1.1.0" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Cyril VERLOOP", | ||
"email": "[email protected]" | ||
} | ||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phive xmlns="https://phar.io/phive"> | ||
<phar name="phpunit" version="^9.5.1" installed="9.5.2" location="./tools/phpunit" copy="true"/> | ||
<phar name="psalm" version="^4.4.1" installed="4.4.1" location="./tools/psalm" copy="true"/> | ||
<phar name="phpcs" version="^3.5.8" installed="3.5.8" location="./tools/phpcs" copy="true"/> | ||
</phive> |
Oops, something went wrong.