Skip to content

Commit

Permalink
Merge pull request #205 from weierophinney/feature/php-8.1-support
Browse files Browse the repository at this point in the history
Provide PHP 8.1 support
  • Loading branch information
Ocramius authored Sep 16, 2021
2 parents af9634d + 7c848c9 commit a7acfdb
Show file tree
Hide file tree
Showing 338 changed files with 6,417 additions and 5,569 deletions.
2 changes: 1 addition & 1 deletion .ci/mysql_fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

echo "Configure MySQL test database"

mysql --user=root --password=Password123 -e 'create database zenddb_test;'
mysql --user=root --password=Password123 -e "create database laminasdb_test;"
2 changes: 1 addition & 1 deletion .ci/pgsql_fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

echo "Configure PostgreSQL test database"

psql -U postgres -c 'create database zenddb_test;'
psql -U postgres -c 'create database laminasdb_test;'
psql -U postgres -c "alter role postgres password 'postgres'"
2 changes: 1 addition & 1 deletion .ci/sqlsrv_fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

echo "Configure SQL server test database"

sqlcmd -S localhost -U sa -P Password123 -Q "CREATE DATABASE zenddb_test;"
sqlcmd -S localhost -U sa -P Password123 -Q "CREATE DATABASE laminasdb_test;"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/.phpcs-cache
/.phpunit.result.cache
/.vagrant/
/clover.xml
/coveralls-upload.json
/docs/html/
Expand Down
5 changes: 4 additions & 1 deletion .laminas-ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@
"pgsql",
"sqlite3",
"sqlsrv"
]
],
"ignore_php_platform_requirements": {
"8.1": true
}
}
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,58 @@
# laminas-db

[![Build Status](https://github.com/laminas/laminas-config/workflows/Continuous%20Integration/badge.svg)](https://github.com/laminas/laminas-config/actions?query=workflow%3A"Continuous+Integration")
[![Build Status](https://github.com/laminas/laminas-db/workflows/Continuous%20Integration/badge.svg)](https://github.com/laminas/laminas-db/actions?query=workflow%3A"Continuous+Integration")

`Laminas\Db` is a component that abstract the access to a Database using an object
oriented API to build the queries. `Laminas\Db` consumes different storage adapters
to access different database vendors such as MySQL, PostgreSQL, Oracle, IBM DB2,
Microsoft Sql Server, PDO, etc.

## Contributing

Please be sure to read the [contributor's guide](/laminas/.github/blob/main/CONTRIBUTING.md) for general information on contributing.
This section outlines specifics for laminas-db.

### Test suites

The `phpunit.xml.dist` file defines two test suites, "unit test" and "integration test".
You can run one or the other using the `--testsuite` option to `phpunit`:

```bash
$ ./vendor/bin/phpunit --testsuite "unit test" # unit tests only
$ ./vendor/bin/phpunit --testsuite "integration test" # integration tests only
```

Unit tests do not require additional functionality beyond having the appropriate database extensions present and loaded in your PHP binary.

### Integration tests

To run the integration tests, you need databases.
The repository includes a `Vagrantfile` which allows you to fire up a [vagrant box](https://app.vagrantup.com) with several of our target databases, including:

- MySQL
- PostgreSQL
- SQL Server

To start up vagrant:

```bash
$ vagrant up
```

Copy `phpunit.xml.dist` to `phpunit.xml`, and change the following ENV var declaration values to "true":

- TESTS_LAMINAS_DB_ADAPTER_DRIVER_MYSQL
- TESTS_LAMINAS_DB_ADAPTER_DRIVER_SQLSRV
- TESTS_LAMINAS_DB_ADAPTER_DRIVER_PGSQL
- TESTS_LAMINAS_DB_ADAPTER_DRIVER_SQLITE_MEMORY

From there, you can run the integration tests:

```bash
$ ./vendor/bin/phpunit --testsuite "integration test"
```

-----

- File issues at https://github.com/laminas/laminas-db/issues
- Documentation is at https://docs.laminas.dev/laminas-db/
31 changes: 20 additions & 11 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ apt-get -yq update
apt-get -yq install postgresql
# Allow external connections to PostgreSQL as postgres
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/9.5/main/postgresql.conf
sed -i "s/peer/trust/" /etc/postgresql/9.5/main/pg_hba.conf
echo 'host all all 0.0.0.0/0 trust' >> /etc/postgresql/9.5/main/pg_hba.conf
sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/" /etc/postgresql/12/main/postgresql.conf
sed -i "s/peer/trust/" /etc/postgresql/12/main/pg_hba.conf
echo 'host all all 0.0.0.0/0 trust' >> /etc/postgresql/12/main/pg_hba.conf
service postgresql restart
# INSTALL MySQL
Expand All @@ -22,20 +22,29 @@ apt-get -yq install mysql-server
# Allow external connections to MySQL as root (with password Password123)
sed -i 's/127\.0\.0\.1/0\.0\.0\.0/g' /etc/mysql/mysql.conf.d/mysqld.cnf
mysql -u root -pPassword123 -e 'USE mysql; UPDATE `user` SET `Host`="%" WHERE `User`="root" AND `Host`="localhost"; DELETE FROM `user` WHERE `Host` != "%" AND `User`="root"; FLUSH PRIVILEGES;'
mysql -h localhost -u root -pPassword123 -e "ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Password123';"
service mysql restart
# INSTALL SQL Server
# More info here: https://www.microsoft.com/en-us/sql-server/developer-get-started/php-ubuntu
# More info here: https://docs.microsoft.com/en-us/sql/linux/sample-unattended-install-ubuntu?view=sql-server-ver15
MSSQL_SA_PASSWORD='Password123'
MSSQL_PID=developer
SQL_INSTALL_AGENT='y'
curl -s https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl -s https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list > /etc/apt/sources.list.d/mssql-server.list
repoargs="$(curl https://packages.microsoft.com/config/ubuntu/20.04/mssql-server-2019.list)"
add-apt-repository "${repoargs}"
repoargs="$(curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list)"
add-apt-repository "${repoargs}"
apt-get -yq update
apt-get -yq install mssql-server
printf "YES\nPassword123\nPassword123\ny\ny" | /opt/mssql/bin/mssql-conf setup
curl -s https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-tools.list
apt-get -yq update
ACCEPT_EULA=Y apt-get -yq install msodbcsql mssql-tools unixodbc-dev
MSSQL_SA_PASSWORD=$MSSQL_SA_PASSWORD \
MSSQL_PID=$MSSQL_PID \
/opt/mssql/bin/mssql-conf -n setup accept-eula
echo "Installing mssql-tools and unixODBC developer..."
ACCEPT_EULA=Y apt-get install -y mssql-tools unixodbc-dev
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> /home/vagrant/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> /home/vagrant/.bashrc
source /home/vagrant/.bashrc
Expand All @@ -49,7 +58,7 @@ fi
SCRIPT

Vagrant.configure(2) do |config|
config.vm.box = 'bento/ubuntu-16.04'
config.vm.box = 'bento/ubuntu-20.04'
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
Expand Down
22 changes: 10 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,19 @@
}
},
"require": {
"php": "^7.3 || ~8.0.0",
"laminas/laminas-stdlib": "^3.3",
"laminas/laminas-zendframework-bridge": "^1.0"
"php": "^7.3 || ~8.0.0 || ~8.1.0",
"laminas/laminas-stdlib": "^3.6"
},
"require-dev": {
"laminas/laminas-coding-standard": "~1.0.0",
"laminas/laminas-eventmanager": "^3.3",
"laminas/laminas-hydrator": "^3.2 || ^4.0",
"laminas/laminas-servicemanager": "^3.3",
"phpspec/prophecy-phpunit": "^2.0",
"phpunit/phpunit": "^9.3"
"laminas/laminas-coding-standard": "~2.2.1",
"laminas/laminas-eventmanager": "^3.4",
"laminas/laminas-hydrator": "^3.2 || ^4.3",
"laminas/laminas-servicemanager": "^3.7",
"phpunit/phpunit": "^9.5.5"
},
"suggest": {
"laminas/laminas-eventmanager": "Laminas\\EventManager component",
"laminas/laminas-hydrator": "(^3.2 || ^4.0) Laminas\\Hydrator component for using HydratingResultSets",
"laminas/laminas-hydrator": "(^3.2 || ^4.3) Laminas\\Hydrator component for using HydratingResultSets",
"laminas/laminas-servicemanager": "Laminas\\ServiceManager component"
},
"autoload": {
Expand All @@ -65,7 +63,7 @@
"test-integration": "phpunit --colors=always --testsuite \"integration test\"",
"upload-coverage": "coveralls -v"
},
"replace": {
"zendframework/zend-db": "^2.11.0"
"conflict": {
"zendframework/zend-db": "*"
}
}
Loading

0 comments on commit a7acfdb

Please sign in to comment.