Skip to content

Commit a80235a

Browse files
committed
:octocat: cleanup, test fixes
1 parent c98eec2 commit a80235a

24 files changed

+504
-195
lines changed

.codeclimate.yml

-21
This file was deleted.

.github/FUNDING.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ko_fi: codemasher
2+
custom: "https://www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4"

.github/workflows/ci.yml

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
2+
# https://github.com/sebastianbergmann/phpunit/blob/master/.github/workflows/ci.yml
3+
4+
name: "Continuous Integration"
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
13+
14+
15+
jobs:
16+
17+
# static-code-analysis:
18+
# name: "Static Code Analysis"
19+
#
20+
# runs-on: ubuntu-latest
21+
#
22+
# env:
23+
# PHAN_ALLOW_XDEBUG: 0
24+
# PHAN_DISABLE_XDEBUG_WARN: 1
25+
#
26+
# steps:
27+
# - name: "Checkout"
28+
# uses: actions/checkout@v2
29+
#
30+
# - name: "Install PHP"
31+
# uses: shivammathur/setup-php@v2
32+
# with:
33+
# php-version: "7.4"
34+
# tools: pecl
35+
# coverage: none
36+
# extensions: ast, curl, json, simplexml, zlib
37+
#
38+
# - name: "Update dependencies with composer"
39+
# run: composer update --no-interaction --no-ansi --no-progress --no-suggest --prefer-source
40+
#
41+
# - name: "Run phan"
42+
# run: php vendor/bin/phan
43+
44+
tests:
45+
name: "Unit Tests"
46+
47+
runs-on: ${{ matrix.os }}
48+
49+
strategy:
50+
fail-fast: false
51+
matrix:
52+
os:
53+
- ubuntu-20.04
54+
- windows-2019
55+
php-version:
56+
- "7.4"
57+
- "8.0"
58+
59+
steps:
60+
- name: "Configure git to avoid issues with line endings"
61+
if: ${{ runner.os == 'Windows' }}
62+
run: git config --global core.autocrlf false
63+
64+
- name: "Checkout"
65+
uses: actions/checkout@v2
66+
67+
# pgsql is already installed on the runner, we just need to start the service
68+
# https://www.cybertec-postgresql.com/en/postgresql-github-actions-continuous-integration/
69+
- name: "Start PostgreSQL (Linux)"
70+
if: ${{ runner.os == 'Linux' }}
71+
# we also need to change the password for the default user under Linux to match the one under Windows
72+
run: |
73+
sudo systemctl start postgresql.service
74+
pg_isready
75+
sudo -u postgres psql --command="ALTER USER postgres PASSWORD 'root';"
76+
sudo -u postgres createdb --echo --owner=postgres dbtest
77+
78+
- name: "Start PostgreSQL (Windows)"
79+
if: ${{ runner.os == 'Windows' }}
80+
run: |
81+
$pgService = Get-Service -Name postgresql*
82+
Set-Service -InputObject $pgService -Status running -StartupType automatic
83+
Start-Process -FilePath "$env:PGBIN\pg_isready" -Wait -PassThru
84+
& $env:PGBIN\createdb --echo --owner=postgres dbtest
85+
86+
- name: "Install MySQL"
87+
uses: shogo82148/actions-setup-mysql@v1
88+
with:
89+
mysql-version: '5.7'
90+
auto-start: true
91+
92+
- name: "Create MySQL test database"
93+
run: mysql --user="root" --host="127.0.0.1" -e "CREATE DATABASE dbtest character set UTF8mb4 collate utf8mb4_bin;"
94+
95+
- name: "Install SQLite (Linux)"
96+
if: ${{ runner.os == 'Linux' }}
97+
run: sudo apt-get -y install sqlite3 libsqlite3-dev
98+
99+
- name: "Install SQLite (Windows)"
100+
if: ${{ runner.os == 'Windows' }}
101+
run: choco install sqlite
102+
103+
# - name: "Install Firebird (Linux)"
104+
# if: ${{ runner.os == 'Linux' }}
105+
# run: |
106+
# sudo add-apt-repository ppa:mapopa/firebird3.0
107+
# sudo apt-get update
108+
# sudo apt-get install -y firebird2.5-superclassic
109+
# sudo cp ./config/firebird.conf /etc/firebird/2.5/firebird.conf
110+
# sudo service firebird2.5 restart
111+
112+
# - name: "Install Firebird (Windows)"
113+
# if: ${{ runner.os == 'Windows' }}
114+
# run: choco install firebird --version=2.5.8 -params '/ClientAndDevTools'
115+
116+
# - name: "Install MSSQL Server (Linux)"
117+
# if: ${{ runner.os == 'Linux' }}
118+
# run: sh ./scripts/install-mssql.sh
119+
120+
# - name: "Start SQL LocalDB (Windows)"
121+
# if: ${{ runner.os == 'Windows' }}
122+
# run: |
123+
# # MSSQLLocalDB is the default SQL LocalDB instance
124+
# SqlLocalDB start MSSQLLocalDB
125+
# SqlLocalDB info MSSQLLocalDB
126+
# sqlcmd -S "(localdb)\MSSQLLocalDB" -Q "create database dbtest;"
127+
128+
- name: "Install PHP with extensions"
129+
uses: shivammathur/setup-php@v2
130+
with:
131+
php-version: ${{ matrix.php-version }}
132+
coverage: pcov
133+
extensions: mbstring, odbc, pdo_odbc, mysqli, pdo_mysql, pgsql, pdo_pgsql, sqlite3, pdo_sqlite, sqlsrv, pdo_sqlsrv, pdo_firebird
134+
# ini-values:
135+
136+
- name: "Install dependencies with composer"
137+
run: composer update --no-ansi --no-interaction --no-progress --no-suggest --prefer-source
138+
139+
- name: "Run tests with phpunit"
140+
run: php vendor/phpunit/phpunit/phpunit --configuration=phpunit.xml.dist
141+
142+
- name: "Send code coverage report to Codecov.io"
143+
uses: codecov/codecov-action@v1
144+
with:
145+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ vendor
55
config/.env
66
storage
77
*.phpunit.result.cache
8+
phpunit.xml

.scrutinizer.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
1+
build:
2+
nodes:
3+
analysis:
4+
tests:
5+
override:
6+
- php-scrutinizer-run
7+
environment:
8+
php: 8.0.0
9+
110
filter:
211
excluded_paths:
312
- config/*
413
- examples/*
5-
- public/*
614
- scripts/*
715
- storage/*
816
- tests/*
917
- vendor/*
18+
- .github/*
19+
- .phan/*

.travis.yml

-25
This file was deleted.

README.md

+23-32
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,55 @@
11
# chillerlan/php-database
22

3-
A PHP 7.2+ SQL client and querybuilder for the most common databases.
3+
A PHP 7.4+ SQL client and querybuilder for the most common databases.
44

5+
[![PHP Version Support][php-badge]][php]
56
[![version][packagist-badge]][packagist]
67
[![license][license-badge]][license]
7-
[![Travis][travis-badge]][travis]
88
[![Coverage][coverage-badge]][coverage]
99
[![Scrunitizer][scrutinizer-badge]][scrutinizer]
10-
[![Packagist downloads][downloads-badge]][downloads]
11-
[![PayPal donate][donate-badge]][donate]
10+
[![Packagist downloads][downloads-badge]][downloads]<br/>
11+
[![Continuous Integration][gh-action-badge]][gh-action]
1212

13-
[packagist-badge]: https://img.shields.io/packagist/v/chillerlan/php-database.svg?style=flat-square
13+
[php-badge]: https://img.shields.io/packagist/php-v/chillerlan/php-oauth-core?logo=php&color=8892BF
14+
[php]: https://www.php.net/supported-versions.php
15+
[packagist-badge]: https://img.shields.io/packagist/v/chillerlan/php-database.svg?logo=packagist
1416
[packagist]: https://packagist.org/packages/chillerlan/php-database
15-
[license-badge]: https://img.shields.io/github/license/chillerlan/php-database.svg?style=flat-square
17+
[license-badge]: https://img.shields.io/github/license/chillerlan/php-database.svg?
1618
[license]: https://github.com/chillerlan/php-database/blob/master/LICENSE
17-
[travis-badge]: https://img.shields.io/travis/chillerlan/php-database.svg?style=flat-square
18-
[travis]: https://travis-ci.org/chillerlan/php-database
19-
[coverage-badge]: https://img.shields.io/codecov/c/github/chillerlan/php-database.svg?style=flat-square
19+
[coverage-badge]: https://img.shields.io/codecov/c/github/chillerlan/php-database.svg?logo=codecov
2020
[coverage]: https://codecov.io/github/chillerlan/php-database
21-
[scrutinizer-badge]: https://img.shields.io/scrutinizer/g/chillerlan/php-database.svg?style=flat-square
21+
[scrutinizer-badge]: https://img.shields.io/scrutinizer/g/chillerlan/php-database.svg?logo=scrutinizer
2222
[scrutinizer]: https://scrutinizer-ci.com/g/chillerlan/php-database
23-
[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-database.svg?style=flat-square
23+
[downloads-badge]: https://img.shields.io/packagist/dt/chillerlan/php-database.svg?logo=packagist
2424
[downloads]: https://packagist.org/packages/chillerlan/php-database/stats
25-
[donate-badge]: https://img.shields.io/badge/donate-paypal-ff33aa.svg?style=flat-square
26-
[donate]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WLYUNAT9ZTJZ4
25+
[gh-action-badge]: https://github.com/chillerlan/php-database/workflows/Continuous%20Integration/badge.svg
26+
[gh-action]: https://github.com/chillerlan/php-database/actions
2727

2828
# Documentation
2929

3030
## Requirements
31-
- PHP 7.2+
32-
- one of the supported databases, set up to work with PHP
33-
34-
## Supported databases
35-
- [MySQL](https://dev.mysql.com/doc/refman/5.6/en/) (5.5+) / [MariaDB](https://mariadb.com/kb/en/library/basic-sql-statements/)
36-
- [PostgreSQL](https://www.postgresql.org/docs/9.5/static/index.html) (9.5+)
37-
- [SQLite3](https://www.sqlite.org/lang.html)
38-
- [Firebird](https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25.html) (2.5+)
39-
- [Microsoft SQL Server](https://github.com/Microsoft/msphpsql) ([transact-sql](https://docs.microsoft.com/sql/t-sql/language-reference))
40-
- any other database supported via PDO, ODBC or native PHP extension
31+
- PHP 7.4+
32+
- one of the supported databases, set up to work with PHP:
33+
- [MySQL](https://dev.mysql.com/doc/refman/5.6/en/) (5.5+) / [MariaDB](https://mariadb.com/kb/en/library/basic-sql-statements/)
34+
- [PostgreSQL](https://www.postgresql.org/docs/9.5/static/index.html) (9.5+)
35+
- [SQLite3](https://www.sqlite.org/lang.html)
36+
- [Firebird](https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25.html) (2.5+)
37+
- [Microsoft SQL Server](https://github.com/Microsoft/msphpsql) ([transact-sql](https://docs.microsoft.com/sql/t-sql/language-reference))
4138

4239
## Installation
4340
**requires [composer](https://getcomposer.org)**
4441

4542
### *composer.json*
46-
(note: replace `dev-master` with a [version boundary](https://getcomposer.org/doc/articles/versions.md#summary))
43+
(note: replace `dev-main` with a [version boundary](https://getcomposer.org/doc/articles/versions.md#summary))
4744
```json
4845
{
4946
"require": {
50-
"php": ">=7.2.0",
51-
"chillerlan/database": "^2.1"
47+
"php": "^7.4",
48+
"chillerlan/database": "dev-main"
5249
}
5350
}
5451
```
5552

56-
### Manual installation
57-
Download the desired version of the package from [master](https://github.com/chillerlan/php-database/archive/master.zip) or
58-
[release](https://github.com/chillerlan/php-database/releases) and extract the contents to your project folder. After that:
59-
- run `composer install` to install the required dependencies and generate `/vendor/autoload.php`.
60-
- if you use a custom autoloader, point the namespace `chillerlan\Database` to the folder `src` of the package
61-
6253
Profit!
6354

6455
## Usage

config/.env_travis

+19-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1-
DB_MYSQLI_HOST=localhost
1+
DB_MYSQLI_HOST=127.0.0.1
2+
#DB_MYSQLI_SOCKET=/tmp/mysql.sock
23
DB_MYSQLI_PORT=3306
34
DB_MYSQLI_DATABASE=dbtest
45
DB_MYSQLI_USERNAME=root
5-
6-
DB_SQLITE3_DATABASE=/home/travis/build/chillerlan/php-database/storage/dbtest.sqlite
7-
SQLITE_MEM_DATABASE=:memory:
6+
DB_MYSQLI_PASSWORD=
87

98
DB_POSTGRES_HOST=localhost
109
DB_POSTGRES_PORT=5432
1110
DB_POSTGRES_DATABASE=dbtest
1211
DB_POSTGRES_USERNAME=postgres
12+
DB_POSTGRES_PASSWORD=root
13+
14+
DB_SQLITE3_DATABASE={STORAGE}dbtest.sqlite
15+
SQLITE_MEM_DATABASE=:memory:
16+
17+
DB_FIREBIRD_HOST=127.0.0.1
18+
DB_FIREBIRD_PORT=3050
19+
#DB_FIREBIRD_SOCKET=
20+
DB_FIREBIRD_DATABASE={STORAGE}dbtest.fdb
21+
DB_FIREBIRD_USERNAME=SYSDBA
22+
DB_FIREBIRD_PASSWORD=masterkey
1323

14-
IS_CI=TRUE
24+
DB_MSSQL_HOST=localhost
25+
DB_MSSQL_PORT=1433
26+
DB_MSSQL_DATABASE=dbtest
27+
DB_MSSQL_USERNAME=SA
28+
DB_MSSQL_PASSWORD=DBtestytest42

examples/common.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
use chillerlan\Database\{
1313
Database,DatabaseOptions,Drivers\MySQLiDrv
1414
};
15-
use chillerlan\Logger\Log;
16-
use chillerlan\Logger\LogOptions;
17-
use chillerlan\Logger\Output\ConsoleLog;
15+
1816
use chillerlan\SimpleCache\MemoryCache;
1917
use chillerlan\DotEnv\DotEnv;
2018
use Psr\Log\LogLevel;
@@ -35,6 +33,5 @@
3533
'password' => $env->get('DB_MYSQLI_PASSWORD'),
3634
]);
3735

38-
$log = (new Log)->addInstance(new ConsoleLog(new LogOptions(['minLogLevel' => LogLevel::DEBUG])), 'console');
3936

4037

examples/dump.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@
1515
/** @var \Psr\SimpleCache\CacheInterface $cache */
1616
$cache = null;
1717

18-
/** @var \Psr\Log\LoggerInterface $log */
19-
$log = null;
20-
2118
require_once __DIR__.'/common.php';
2219

2320
$options->storage_path = __DIR__.'/../storage';
2421

25-
$dumper = new Dumper($options, $cache, $log);
22+
$dumper = new Dumper($options, $cache);
2623

27-
#$dumper->dump(['gw2_*', 'items_'], ['gw2_player_pos', 'gw2_language', 'gw2_items_test', 'gw2_current_matches']);
24+
$dumper->dump(['gw2_*', 'items_'], ['gw2_worlds1', 'gw2_player_pos', 'gw2_language', 'gw2_items_test', 'gw2_items', 'gw2_config', 'gw2_diff', 'gw2_current_matches']);
2825
$dumper->dump(['gw2_items_temp']);
2926

examples/querybuilder.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717
/** @var \Psr\SimpleCache\CacheInterface $cache */
1818
$cache = null;
1919

20-
/** @var \Psr\Log\LoggerInterface $log */
21-
$log = null;
22-
2320
require_once __DIR__.'/common.php';
2421

25-
$db = new Database($options, $cache, $log);
22+
$db = new Database($options, $cache);
2623
$db->connect();
2724

2825
$db->create

0 commit comments

Comments
 (0)