Skip to content

Commit d83dcc6

Browse files
committed
version php82
0 parents  commit d83dcc6

16 files changed

Lines changed: 4677 additions & 0 deletions

.github/workflows/php.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
17+
- name: Setup PHP Action
18+
uses: shivammathur/setup-php@2.26.0
19+
with:
20+
php-version: 8.2
21+
extensions: dom
22+
coverage: xdebug
23+
24+
- name: Validate composer.json and composer.lock
25+
run: composer validate
26+
27+
- name: Cache Composer packages
28+
id: composer-cache
29+
uses: actions/cache@v3
30+
with:
31+
path: vendor
32+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
33+
restore-keys: |
34+
${{ runner.os }}-php-
35+
36+
- name: Install dependencies
37+
if: steps.composer-cache.outputs.cache-hit != 'true'
38+
run: composer install --prefer-dist --no-progress --no-suggest
39+
40+
- name: Run validations
41+
run: composer check
42+
43+
- name: export coverage
44+
run: |
45+
export CODECOV_TOKEN="${{ secrets.CODECOV_TOKEN }}"
46+
bash <(curl -s https://codecov.io/bash)

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
coverage
2+
vendor
3+
.scannerwork
4+
.phpunit.result.cache

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# PHP Database Cache
2+
3+
[![Latest Version](https://img.shields.io/github/v/release/not-empty/database-cache-php-lib.svg?style=flat-square)](https://github.com/not-empty/database-cache-php-lib/releases)
4+
[![codecov](https://codecov.io/gh/not-empty/database-cache-php-lib/graph/badge.svg?token=AEMV163UW6)](https://codecov.io/gh/not-empty/database-cache-php-lib)
5+
[![CI Build](https://img.shields.io/github/actions/workflow/status/not-empty/database-cache-php-lib/php.yml)](https://github.com/not-empty/database-cache-php-lib/actions/workflows/php.yml)
6+
[![Downloads Old](https://img.shields.io/packagist/dt/kiwfy/database-cache-php?logo=old&label=downloads%20legacy)](https://packagist.org/packages/kiwfy/database-cache-php)
7+
[![Downloads](https://img.shields.io/packagist/dt/not-empty/database-cache-php-lib?logo=old&label=downloads)](https://packagist.org/packages/not-empty/database-cache-php-lib)
8+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
9+
[![Packagist License (custom server)](https://img.shields.io/packagist/l/not-empty/database-cache-php-lib)](https://github.com/not-empty/database-cache-php-lib/blob/master/LICENSE)
10+
11+
PHP library for put all database result in cache
12+
13+
### Installation
14+
15+
[Release 6.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/6.0.0) Requires [PHP](https://php.net) 8.2
16+
17+
[Release 5.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/5.0.0) Requires [PHP](https://php.net) 8.1
18+
19+
[Release 4.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/4.0.0) Requires [PHP](https://php.net) 7.4
20+
21+
[Release 3.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/3.0.0) Requires [PHP](https://php.net) 7.3
22+
23+
[Release 2.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/2.0.0) Requires [PHP](https://php.net) 7.2
24+
25+
[Release 1.0.0](https://github.com/not-empty/database-cache-php-lib/releases/tag/1.0.0) Requires [PHP](https://php.net) 7.1
26+
27+
The recommended way to install is through [Composer](https://getcomposer.org/).
28+
29+
```sh
30+
composer require not-empty/database-cache-php-lib
31+
```
32+
33+
### Usage
34+
35+
Setting a credential
36+
37+
```php
38+
use DatabaseCache\Repository;
39+
$redisConfig = [
40+
'host' => 'localhost',
41+
'port' => 6379,
42+
];
43+
$repository = new Repository($redisConfig);
44+
$data = [
45+
'name' => 'gabriel',
46+
'email' => 'testegabs@teste.com',
47+
];
48+
$repository->setQuery(
49+
'table:id',
50+
json_encode($data)
51+
);
52+
$getData = $repository->getQuery('table:id');
53+
var_dump($data);
54+
```
55+
56+
if you want an environment to run or test it, you can build and install dependences like this
57+
58+
```sh
59+
docker build --build-arg PHP_VERSION=8.2-cli -t not-empty/database-cache-php-lib:php82 -f contrib/Dockerfile .
60+
```
61+
62+
Access the container
63+
```sh
64+
docker run -v ${PWD}/:/var/www/html -it not-empty/database-cache-php-lib:php82 bash
65+
```
66+
67+
Verify if all dependencies is installed
68+
```sh
69+
composer install --no-dev --prefer-dist
70+
```
71+
72+
and run
73+
```sh
74+
php sample/repository-sample.php
75+
```
76+
77+
### Development
78+
79+
Want to contribute? Great!
80+
81+
The project using a simple code.
82+
Make a change in your file and be careful with your updates!
83+
**Any new code will only be accepted with all validations.**
84+
85+
To ensure that the entire project is fine:
86+
87+
First you need to building a correct environment to install all dependences
88+
89+
```sh
90+
docker build --build-arg PHP_VERSION=8.2-cli -t not-empty/database-cache-php-lib:php82 -f contrib/Dockerfile .
91+
```
92+
93+
Access the container
94+
```sh
95+
docker run -v ${PWD}/:/var/www/html -it not-empty/database-cache-php-lib:php82 bash
96+
```
97+
98+
Install all dependences
99+
```sh
100+
composer install --dev --prefer-dist
101+
```
102+
103+
Run all validations
104+
```sh
105+
composer check
106+
```
107+
108+
**Not Empty Foundation - Free codes, full minds**

composer.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "not-empty/database-cache-php-lib",
3+
"description": "PHP library for put all database result in cache",
4+
"version": "6.0.0",
5+
"type": "library",
6+
"license": "GPL-3.0-only",
7+
"require": {
8+
"php": "^8.2",
9+
"predis/predis": "^2.2"
10+
},
11+
"authors": [
12+
{
13+
"name": "Not Empty Foundation",
14+
"email": "dev@not-empty.com"
15+
}
16+
],
17+
"autoload": {
18+
"psr-4": {
19+
"DatabaseCache\\": "src/"
20+
}
21+
},
22+
"scripts": {
23+
"post-install-cmd": [
24+
"bash contrib/setup.sh"
25+
],
26+
"check": [
27+
"@lint",
28+
"@cs",
29+
"@mess",
30+
"@test",
31+
"@ccu"
32+
],
33+
"mess" : [
34+
"vendor/bin/phpmd ./src text phpmd.xml",
35+
"vendor/bin/phpmd ./sample text phpmd.xml"
36+
],
37+
"lint": [
38+
"find ./src -name '*.php' -print0 | xargs -0 -n1 -P8 php -l -d display_errors=0",
39+
"find ./tests -name '*.php' -print0 | xargs -0 -n1 -P8 php -l -d display_errors=0",
40+
"find ./sample -name '*.php' -print0 | xargs -0 -n1 -P8 php -l -d display_errors=0"
41+
],
42+
"cs": "vendor/bin/phpcs",
43+
"test": "phpdbg -qrr vendor/bin/phpunit --configuration phpunit.xml -d memory_limit=1024M",
44+
"ccu" : "php contrib/coverage-checker.php coverage/coverage.xml 100"
45+
},
46+
"require-dev": {
47+
"phpunit/phpunit": "^9.6",
48+
"mockery/mockery": "^1.6",
49+
"squizlabs/php_codesniffer": "^3.7",
50+
"phpmd/phpmd": "^2.14"
51+
}
52+
}

0 commit comments

Comments
 (0)