diff --git a/.gitignore b/.gitignore index a8af03c..8345dc1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,5 @@ # # https://help.github.com/articles/ignoring-files/#create-a-global-gitignore -wip/ -vendor/ - -composer.phar +/provider/*/vendor/ +/vendor/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e83b8d5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,85 @@ +sudo: false +dist: trusty + +language: php + +php: + - 7.0 + - 7.1 + - 7.2 + - nightly + +matrix: + fast_finish: true + allow_failures: + - php: nightly + +git: + depth: 1 + +env: + global: + - CC="ccache gcc" + - PHALCON_VERSION=v3.3.0 + - PATH=/root/.composer/vendor/bin:$PATH + # TODO + - HAS_CACHING_METADATA_SUPPORT=0 + matrix: + - PROVIDER=activerecord + - PROVIDER=cake + - PROVIDER=doctrine + - PROVIDER=eloquent + - PROVIDER=phalcon + - PROVIDER=propel + - PROVIDER=yii + +cache: + # See: https://github.com/travis-ci/travis-ci/issues/8714 + edge: true + apt: true + ccache: true + timeout: 604800 + directories: + - .temp + - $HOME/.ccache + - $HOME/.composer/cache + - $HOME/pear + - $HOME/.cache/src + - $HOME/.local/lib + +before_install: + - ulimit -c unlimited -S || true + - phpenv config-rm xdebug.ini || true + - if [[ ! -z "${GH_TOKEN}" ]]; then composer config github-oauth.github.com ${GH_TOKEN}; echo "Configured Github token"; fi; + - if [[ $PROVIDER == "phalcon" ]]; then bash $TRAVIS_BUILD_DIR/ci/install_phalcon.sh; fi; + - if [[ $PROVIDER == "yii" ]]; then composer global require --prefer-dist --no-interaction --no-suggest "fxp/composer-asset-plugin:~1.4"; fi; + +install: + - (cd $TRAVIS_BUILD_DIR/provider/$PROVIDER; composer install --no-dev --no-interaction --prefer-dist --no-suggest --optimize-autoloader) + - (cd $TRAVIS_BUILD_DIR; composer install --no-dev --no-interaction --prefer-dist --no-suggest --optimize-autoloader) + - phpenv config-add $TRAVIS_BUILD_DIR/ci/benchmark.ini + - ls -al `$(phpenv which php-config) --extension-dir` + - $(phpenv which php) -v + - $(phpenv which php) -m + - echo 'SHOW VARIABLES LIKE "%version%"' | mysql -u root + +before_script: + - echo 'CREATE DATABASE orm_benchmark CHARSET=utf8 COLLATE=utf8_unicode_ci' | mysql -u root + - echo "CREATE USER 'enigma'@'%' IDENTIFIED BY 'secret'" | mysql -u root + - echo "GRANT ALL PRIVILEGES ON orm_benchmark.* TO 'enigma'@'%' WITH GRANT OPTION" | mysql -u root + - cat schema/orm-benchmark.sql | mysql -u root orm_benchmark + +script: + - cd $TRAVIS_BUILD_DIR + - php run $PROVIDER read 1 + - php run $PROVIDER read 10 + - php run $PROVIDER create 1 + - php run $PROVIDER create 10 + - if [[ $HAS_CACHING_METADATA_SUPPORT == 1 ]]; then php run $PROVIDER read 1 1; fi; + - if [[ $HAS_CACHING_METADATA_SUPPORT == 1 ]]; then php run $PROVIDER read 10 1; fi; + +notifications: + # Stop spam me. I already live on Travis CI and GitHub + email: + on_success: never + on_failure: never diff --git a/README.md b/README.md index dc67f8f..fd0509e 100644 --- a/README.md +++ b/README.md @@ -1,221 +1,42 @@ -# PHP ORM Benchmark - -The Docker based project to facilitate PHP ORM benchmarks. - -## Contents [↑](#php-orm-benchmark) - -* [Requirements](#requirements-) -* [ORMs to Benchmark](#orms-to-benchmark-) -* [Getting Started](#getting-started-) - * [Running Benchmark](#running-benchmark-) - * [Results](#results-) - * [Benchmarking Environment](#benchmarking-environment-) - * [First run](#first-run-) - * [Insert a record to the Database](#insert-a-record-to-the-database-) - * [Get first record with relation](#get-first-record-with-relation-) - * [10-fold method call](#10-fold-method-call-) - * [Insert a record to the Database](#insert-a-record-to-the-database--1) - * [Get first record with relation](#get-first-record-with-relation--1) - * [First run with metadata caching](#first-run-with-metadata-caching-) - * [Get first record with relation](#get-first-record-with-relation--2) - * [10-fold method call with metadata caching](#10-fold-method-call-with-metadata-caching-) - * [Get first record with relation](#get-first-record-with-relation--3) -* [Contributing](#contributing-) -* [Discussion](#discussion-) -* [References](#references-) -* [License](#license-) - -## Requirements [↑](#php-orm-benchmark) - -* Linux or BDS System -* Docker CE/EE >= 17.09.0 -* Docker Compose >= 1.17 -* PHP >= 7.0 -* Composer - -## ORMs to Benchmark [↑](#php-orm-benchmark) +# PHP ORM Benchmark [![Build Status](https://travis-ci.org/sergeyklay/php-orm-benchmark.svg?branch=master)](https://travis-ci.org/sergeyklay/php-orm-benchmark) -* Phalcon 3.3.0 -* Propel ORM 2.0.0-alpha7 -* Eloquent 5.5.28 -* CakePHP ORM 3.5.10 -* Yii ActiveRecord 2.0.13.1 -* Doctrine ORM 2.5.14 -* PHP ActiveRecord 1.2.0 - -## Getting Started [↑](#php-orm-benchmark) - -First you have to build the benchmark application. Go to project root and run command as follows: - -```sh -git clone git@github.com:sergeyklay/php-orm-benchmark.git -cd php-orm-benchmark -docker-compose build --force-rm --no-cache -``` - -I advise you to rely on [Composer](https://getcomposer.org) to manage projects’ dependencies. -You have to download and install Composer itself in a common location or in project root by executing in a terminal the command like this: - -```sh -$ wget http://getcomposer.org/composer.phar -# If you haven't wget on your computer -$ curl -s http://getcomposer.org/installer | php -``` - -Then, to install all project's dependencies, type the following from the project root: - -```sh -php composer.phar install -``` - -**Note:** You may skip Phalcon by running `php composer.phar install --ignore-platform-reqs`, if you don't have it installed at host system. - -Finally, start the benchmark application: - -```sh -docker-compose run benchmark -``` - -### Running Benchmark [↑](#php-orm-benchmark) - -To run benchmark simple run command as follows: - -```sh -php run -``` - -Available providers are: - -* `phalcon` -* `propel` -* `eloquent` -* `cake` -* `yii` -* `doctrine` -* `activerecord` - -Available tests are: - -* `create` -* `read` - -To run benchmark multiple times use: +The benchmark to compare different ORM solutions for PHP. -```sh -php run -``` +Initially this project used Docker to facilitate PHP ORM benchmarks. But after [repeated](https://github.com/sergeyklay/php-orm-benchmark/pull/12) [comments](https://github.com/sergeyklay/php-orm-benchmark/issues/7) I decided to transfer the benchmarks to [Travis CI](https://travis-ci.org/sergeyklay/php-orm-benchmark). -Some ORMs rely (depends) on models metadata caching. Thus, to avoid [controversy](https://github.com/sergeyklay/php-orm-benchmark/issues/4) -there is an ability to create and run test with metadata caching support. To use models metadata caching (if supports) you can use the -4th command line argument as follows: +So everyone [can see the results](https://travis-ci.org/sergeyklay/php-orm-benchmark) or run them again. Actually I've enabled the daily [cron job on Travis CI](https://docs.travis-ci.com/user/cron-jobs/). -```sh -php run 1 -``` +NOTE: Some ORMs rely (depends) on models metadata caching. Thus, to avoid [controversy](https://github.com/sergeyklay/php-orm-benchmark/issues/4) there is an ability to create and run test with metadata caching support. -To destroy the application use the following command from the host system: +## ORMs to Benchmark -```sh -docker-compose down -docker volume rm phpormbenchmark_mysql -``` - -## Results [↑](#php-orm-benchmark) - -These are my benchmarks, not yours. **I encourage you to run on your (production equivalent) environments.** -By sharing underlying software stacks, the benchmark results vary only according to the host machine's hardware specs and differing code implementations. - -### Benchmarking Environment [↑](#php-orm-benchmark) - -* Debian GNU/Linux 8.10 (jessie) 64bit (Docker) -* PHP 7.0.26 -* Zend OPcache 7.0.26 -* MySQL 5.7 - -### First run [↑](#php-orm-benchmark) - -#### Insert a record to the Database [↑](#php-orm-benchmark) - -| ORM | Elapsed time (ms) | Used memory (KiB) | Total memory usage (KiB) | Method | -|-------------------|--------------------:|------------------:|-------------------------:|--------------| -| Doctrine | 180.52 | 764.05 | 1,992,804.41 | `flush` | -| CakePHP | 288.97 | 836.86 | 1,546,380.41 | `save` | -| Eloquent | 130.20 | 520.95 | 1,530,852.41 | `save` | -| Propel | 101.60 | 278.77 | 977,372.41 | `save` | -| Yii | 40.72 | 225.01 | 1,180,652.41 | `save` | -| PHP ActiveRecord | 28.12 | 118.91 | 804,852.41 | `save` | -| Phalcon | 9.13 | 32.66 | 720,812.41 | `save` | - -#### Get first record with relation [↑](#php-orm-benchmark) - -| ORM | Elapsed time (ms) | Used memory (KiB) | Total memory usage (KiB) | Method | -|-------------------|--------------------:|------------------:|-------------------------:|--------------| -| Doctrine | 202.51 | 798.64 | 2,028,596.41 | `findOneBy` | -| CakePHP | 282.98 | 977.05 | 1,690,308.41 | `find` | -| Eloquent | 127.85 | 559.12 | 1,570,316.41 | `firstOrFail`| -| Propel | 154.12 | 725.33 | 1,435,020.41 | `findPk` | -| Yii | 69.66 | 325.98 | 1,284,428.41 | `findOne` | -| PHP ActiveRecord | 28.19 | 57.23 | 742,100.41 | `first` | -| Phalcon | 10.79 | 67.12 | 756,092.41 | `findFirst` | - -### 10-fold method call [↑](#php-orm-benchmark) - -#### Insert a record to the Database [↑](#php-orm-benchmark) - -| ORM | Elapsed time (ms) | Used memory (KiB) | Total memory usage (KiB) | Method | -|-------------------|--------------------:|------------------:|-------------------------:|--------------| -| Doctrine | 19.36 | 78.26 | 2,011,436.41 | `flush` | -| CakePHP | 24.61 | 83.72 | 1,546,380.41 | `save` | -| Eloquent | 14.80 | 52.13 | 1,530,852.41 | `save` | -| Propel | 9.05 | 28.16 | 979,996.41 | `save` | -| Yii | 5.46 | 23.94 | 1,195,028.41 | `save` | -| PHP ActiveRecord | 4.98 | 11.95 | 804,852.41 | `save` | -| Phalcon | 2.13 | 3.33 | 721,420.41 | `save` | - -#### Get first record with relation [↑](#php-orm-benchmark) - -| ORM | Elapsed time (ms) | Used memory (KiB) | Total memory usage (KiB) | Method | -|-------------------|--------------------:|------------------:|-------------------------:|--------------| -| Doctrine | 18.96 | 83.29 | 2,063,724.41 | `findOneBy` | -| CakePHP | 29.33 | 97.70 | 1,690,308.41 | `find` | -| Eloquent | 13.55 | 55.91 | 1,570,316.41 | `firstOrFail`| -| Propel | 15.44 | 73.15 | 1,441,348.41 | `findPk` | -| Yii | 8.03 | 35.40 | 1,313,084.41 | `findOne` | -| PHP ActiveRecord | 2.95 | 5.72 | 742,100.41 | `first` | -| Phalcon | 1.54 | 15.54 | 846,444.41 | `findFirst` | - -### First run with metadata caching [↑](#php-orm-benchmark) - -#### Get first record with relation [↑](#php-orm-benchmark) - -| ORM | Elapsed time (ms) | Used memory (KiB) | Total memory usage (KiB) | MetaData Storage | -|-------------------|--------------------:|------------------:|-------------------------:|------------------| -| Doctrine | 145.61 | 264.44 | 2,033,836.41 | File System | -| CakePHP | 273.66 | 1,075.52 | 1,793,772.41 | File System | -| Phalcon | 18.69 | 60.75 | 750,268.41 | File System | - -### 10-fold method call with metadata caching [↑](#php-orm-benchmark) +* CakePHP ORM 3.5.10 +* Doctrine ORM 2.5.14 +* Eloquent 5.5.28 +* PHP ActiveRecord 1.2.0 +* Phalcon 3.3.0 +* Propel ORM 2.0.0-alpha7 +* Yii ActiveRecord 2.0.13.1 -#### Get first record with relation [↑](#php-orm-benchmark) +## Benchmarking Environment -| ORM | Elapsed time (ms) | Used memory (KiB) | Total memory usage (KiB) | MetaData Storage | -|-------------------|--------------------:|------------------:|-------------------------:|------------------| -| Doctrine | 15.65 | 29.87 | 2,068,964.41 | File System | -| CakePHP | 30.18 | 107.55 | 1,793,772.41 | File System | -| Phalcon | 2.27 | 14.90 | 840,620.41 | File System | +* Ubuntu 14.04.5 (Trusty) 64bit (Travis CI) +* PHP 7.0, 7.1, 7.2, 7.3 +* Zend OPcache 7.0, 7.1, 7.2, 7.3 +* MySQL 5.6 -## Contributing [↑](#php-orm-benchmark) +## What we test -The source for this extension is available on [GitHub](https://github.com/sergeyklay/php-orm-benchmark). If anyone feels that there is -something missing or would like to suggest improvements please [open a new issue](https://github.com/sergeyklay/php-orm-benchmark/issues) -or send a pull request. +* Insert a record to the Database +* Get first record with relation +* Insert a record to the Database (10-fold method call) +* Get first record with relation (10-fold method call) -## Discussion [↑](#php-orm-benchmark) +## Contributing -There is an `#general` channel on the Phalcon [Discord Server](https://discord.gg/PNFsSsr). -If you would like to discuss an idea or need help or have other feedback you can usually find me (`@klay`) idling there. +Contributions for new ORMs are more than welcome! If anyone feels that there is something missing or would like to suggest improvements please [open a new issue](https://github.com/sergeyklay/php-orm-benchmark/issues) or send a pull request. -## References [↑](#php-orm-benchmark) +## References * [Eloquent ORM](https://laravel.com/docs/5.5/eloquent) * [Phalcon ORM](https://docs.phalconphp.com/en/3.2/db-models) @@ -225,10 +46,9 @@ If you would like to discuss an idea or need help or have other feedback you can * [Doctrine ORM](http://www.doctrine-project.org/projects/orm.html) * [PHP ActiveRecord](http://www.phpactiverecord.org/projects/main/wiki) -## License [↑](#php-orm-benchmark) +## License -The "PHP ORM Benchmark" is open source software licensed under the MIT License. -See the [LICENSE](https://github.com/sergeyklay/php-orm-benchmark/blob/master/LICENSE) file for more. +The "PHP ORM Benchmark" is open source software licensed under the MIT License. See the [LICENSE](https://github.com/sergeyklay/php-orm-benchmark/blob/master/LICENSE) file for more. --- diff --git a/config/benchmark.ini b/ci/benchmark.ini similarity index 100% rename from config/benchmark.ini rename to ci/benchmark.ini diff --git a/ci/install_phalcon.sh b/ci/install_phalcon.sh new file mode 100644 index 0000000..a746e8f --- /dev/null +++ b/ci/install_phalcon.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# Ensure that this is being run inside a CI container +if [ "${CI}" != "true" ]; then + echo "This script is designed to run inside a CI container only. Exiting" + exit 1 +fi + +PHALCON_VERSION=${PHALCON_VERSION:-master} +PHP_MAJOR=`$(phpenv which php-config) --version | cut -d '.' -f 1,2` + +LOCAL_SRC_DIR=${HOME}/.cache/src/phalcon/${PHALCON_VERSION} +LOCAL_LIB_DIR=${HOME}/.local/lib +LOCAL_LIBRARY=${LOCAL_LIB_DIR}/phalcon-${PHALCON_VERSION}-${PHP_MAJOR}.so + +PHALCON_INI_FILE=${HOME}/.phpenv/versions/$(phpenv version-name)/etc/conf.d/50-phalcon.ini + +EXTENSION_DIR=`$(phpenv which php-config) --extension-dir` + +if [ ! -f ${LOCAL_LIBRARY} ]; then + mkdir -p ${LOCAL_SRC_DIR} + mkdir -p ${LOCAL_LIB_DIR} + + if [ ! -f ${LOCAL_SRC_DIR}/config.json ]; then + rm -rf ${LOCAL_SRC_DIR}/* + git clone --depth=1 -v https://github.com/phalcon/cphalcon.git -b ${PHALCON_VERSION} ${LOCAL_SRC_DIR} + fi + + cd ${LOCAL_SRC_DIR}/build + + ./install --phpize $(phpenv which phpize) --php-config $(phpenv which php-config) + + if [ ! -f "${EXTENSION_DIR}/phalcon.so" ]; then + echo "Unable to locate installed phalcon.so" + exit 1 + fi + + cp "${EXTENSION_DIR}/phalcon.so" ${LOCAL_LIBRARY} +fi + +echo "[Phalcon]" > ${PHALCON_INI_FILE} +echo "extension=${LOCAL_LIBRARY}" >> ${PHALCON_INI_FILE} + +php --ri phalcon || exit 1 diff --git a/config/activerecord.php b/config/activerecord.php index 12a4372..f21d6ff 100644 --- a/config/activerecord.php +++ b/config/activerecord.php @@ -1,5 +1,5 @@ 'mysql://enigma:secret@mysql/orm_benchmark', + 'dsn' => 'mysql://enigma:secret@127.0.0.1/orm_benchmark', ]; diff --git a/config/cake.php b/config/cake.php index 0c4e781..8080de6 100644 --- a/config/cake.php +++ b/config/cake.php @@ -10,7 +10,7 @@ 'database' => [ 'className' => Connection::class, 'driver' => Mysql::class, - 'host' => 'mysql', + 'host' => '127.0.0.1', 'port' => 3306, 'database' => 'orm_benchmark', 'username' => 'enigma', diff --git a/config/doctrine.php b/config/doctrine.php index 33f27c0..ebc7bc9 100644 --- a/config/doctrine.php +++ b/config/doctrine.php @@ -2,7 +2,7 @@ return [ 'driver' => 'pdo_mysql', - 'host' => 'mysql', + 'host' => '127.0.0.1', 'dbname' => 'orm_benchmark', 'user' => 'enigma', 'password' => 'secret', diff --git a/config/eloquent.php b/config/eloquent.php index 87f64d9..7a9b555 100644 --- a/config/eloquent.php +++ b/config/eloquent.php @@ -2,7 +2,7 @@ return [ 'driver' => 'mysql', - 'host' => 'mysql', + 'host' => '127.0.0.1', 'database' => 'orm_benchmark', 'username' => 'enigma', 'password' => 'secret', diff --git a/config/grcat b/config/grcat deleted file mode 100644 index 72c450c..0000000 --- a/config/grcat +++ /dev/null @@ -1,54 +0,0 @@ -# Default word color -regexp=.+ -colours=green -- - -# Table borders -regexp=[+\-]+[+\-]|[|] -colours=red -- - -# Data in ( ) and ' ' -regexp=\([\w\d,']+\) -colours=white -- - -# Numeric -regexp=\s[\d\.]+\s*($|(?=\|)) -colours=yellow -- - -# Date -regexp=\d{4}-\d{2}-\d{2} -colours=blue -- - -# Time -regexp=\d{2}:\d{2}:\d{2} -colours=cyan -- - -# IP -regexp=(\d{1,3}\.){3}\d{1,3}(:\d{1,5})? -colours=cyan -- - -# Schema -regexp=`\w+` -colours=yellow -- - -# Email -regexp=[\w\.\-_]+@[\w\.\-_]+ -colours=magenta -- - -# Row delimeter when using \G key -regexp=[*]+.+[*]+ -count=stop -colours=white -- - -# Column names when using \G key -regexp=^\s*\w+: -colours=white diff --git a/config/my.cnf b/config/my.cnf deleted file mode 100644 index 4205655..0000000 --- a/config/my.cnf +++ /dev/null @@ -1,8 +0,0 @@ -[mysql] -default-character-set=utf8 -local-infile=1 -show-warnings -auto-rehash -sigint-ignore -reconnect -pager = grcat ~/.grcat diff --git a/config/phalcon.php b/config/phalcon.php index f293ad2..90e7f23 100644 --- a/config/phalcon.php +++ b/config/phalcon.php @@ -4,7 +4,7 @@ return [ 'database' => [ - 'host' => 'mysql', + 'host' => '127.0.0.1', 'port' => 3306, 'username' => 'enigma', 'password' => 'secret', diff --git a/config/propel.php b/config/propel.php index 74ff368..a5fd731 100644 --- a/config/propel.php +++ b/config/propel.php @@ -1,16 +1,18 @@ ConnectionWrapper::class, - 'dsn' => 'mysql:host=mysql;port=3306;dbname=orm_benchmark', + 'dsn' => 'mysql:host=127.0.0.1;port=3306;dbname=orm_benchmark', 'user' => 'enigma', 'password' => 'secret', 'settings' => [ 'charset' => 'utf8', ], 'model_paths' => [ - dirname(dirname(__FILE__)) . '/src/Models/Propel', + DOCROOT . '/provider/propel/Models', ], ]; diff --git a/config/yii.php b/config/yii.php index 695be76..67bda86 100644 --- a/config/yii.php +++ b/config/yii.php @@ -1,7 +1,7 @@ 'mysql:host=mysql;port=3306;dbname=orm_benchmark', + 'dsn' => 'mysql:host=127.0.0.1;port=3306;dbname=orm_benchmark', 'username' => 'enigma', 'password' => 'secret', 'charset' => 'utf8', diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index 7785f48..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: '3.0' - -services: - benchmark: - build: ./docker/php/image - image: php-orm-benchmark:1.0.0 - depends_on: - - mysql - working_dir: '/app' - volumes: - - .:/app:rw - - ./config/grcat:/root/.grcat:ro - - ./config/my.cnf:/root/.my.cnf:ro - - ./config/benchmark.ini:/usr/local/etc/php/conf.d/999-php-orm-benchmark.ini:ro - command: '/bin/bash' - - mysql: - image: mysql/mysql-server:5.7 - volumes: - - ./schema/orm-benchmark.sql:/docker-entrypoint-initdb.d/orm-benchmark.sql:ro - - mysql:/var/lib/mysql - ports: - - "127.0.0.1:3306:3306" - environment: - MYSQL_DATABASE: orm_benchmark - MYSQL_USER: enigma - MYSQL_PASSWORD: secret - MYSQL_ROOT_HOST: "%" - -volumes: - mysql: - driver: local diff --git a/docker/php/image/Dockerfile b/docker/php/image/Dockerfile deleted file mode 100644 index 67ad05e..0000000 --- a/docker/php/image/Dockerfile +++ /dev/null @@ -1,82 +0,0 @@ -FROM php:7.0.26-cli - -LABEL maintainer="Serghei Iakovlev " -LABEL version="1.0.0" - -ENV PHALCON_VERSION=3.3.0 \ - DEBIAN_FRONTEND=noninteractive \ - COMPOSER_HOME=/root/.composer \ - COMPOSER_ALLOW_SUPERUSER=1 \ - PATH=/root/.composer/vendor/bin:$PATH \ - TERM=xterm - -WORKDIR /tmp - -RUN echo exit 101 > /usr/sbin/policy-rc.d \ - && chmod +x /usr/sbin/policy-rc.d \ - && echo "force-unsafe-io" > /etc/dpkg/dpkg.cfg.d/02apt-speedup \ - && echo "Acquire::http {No-Cache=True;};" > /etc/apt/apt.conf.d/no-cache \ - && apt-get update \ - && apt-get upgrade -y -q \ - && apt-get install -y -q --no-install-recommends apt-utils software-properties-common - -RUN apt-get install -y -q --no-install-recommends \ - build-essential \ - git \ - grc \ - less \ - libcurl3-dev \ - libicu-dev \ - libpcre3-dev \ - libpq-dev \ - libsqlite3-dev \ - libssl-dev \ - libxml2-dev \ - locales \ - mysql-client \ - postgresql-client \ - sqlite3 \ - vim \ - wget \ - zlib1g-dev - -RUN docker-php-ext-configure intl 1>/dev/null \ - && docker-php-ext-install intl 1>/dev/null \ - && docker-php-ext-configure mysqli --with-mysqli=mysqlnd 1>/dev/null \ - && docker-php-ext-install mysqli 1>/dev/null \ - && docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd 1>/dev/null \ - && docker-php-ext-install pdo_mysql 1>/dev/null \ - && docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql 1>/dev/null \ - && docker-php-ext-install pgsql pdo_pgsql zip 1>/dev/null \ - && docker-php-ext-enable opcache \ - && php -m - -RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ - && php composer-setup.php --install-dir=/usr/local/bin/ --filename=composer \ - && rm composer-setup.php \ - && composer --version - -RUN composer global require --no-ansi --prefer-dist --no-interaction --no-suggest "fxp/composer-asset-plugin:~1.4" - -RUN curl -sSLO https://codeload.github.com/phalcon/cphalcon/tar.gz/v$PHALCON_VERSION \ - && tar xzf v$PHALCON_VERSION \ - && cd cphalcon-$PHALCON_VERSION/build \ - && ./install --phpize /usr/local/bin/phpize --php-config /usr/local/bin/php-config 1>/dev/null \ - && echo "extension=`php-config --extension-dir`/phalcon.so" > $PHP_INI_DIR/conf.d/docker-php-ext-phalcon.ini \ - && php --ri phalcon - -RUN apt-get autoremove -y \ - && apt-get autoclean -y \ - && apt-get clean -y \ - && rm -rf \ - /var/lib/apt/lists/* \ - /tmp/* \ - /var/tmp/* \ - /etc/php5 \ - /etc/php/5* \ - /usr/lib/php/20121212 \ - /usr/lib/php/20131226 \ - /var/log \ - /var/cache - -WORKDIR /app \ No newline at end of file diff --git a/provider/activerecord/composer.json b/provider/activerecord/composer.json index dcf5b3a..0856fbb 100644 --- a/provider/activerecord/composer.json +++ b/provider/activerecord/composer.json @@ -3,11 +3,6 @@ "php": ">=7.0.0", "php-activerecord/php-activerecord": "1.2.0" }, - "config": { - "platform": { - "php": "7.0.26" - } - }, "autoload": { "psr-4": { "OrmBench\\Activerecord\\": "./" diff --git a/provider/activerecord/composer.lock b/provider/activerecord/composer.lock index 0694672..a49d5f7 100644 --- a/provider/activerecord/composer.lock +++ b/provider/activerecord/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "fc0c63fff9901b61c56649b6eb53e851", + "content-hash": "78ae5a60c05f8a4fc31a51233ea5b08f", "packages": [ { "name": "php-activerecord/php-activerecord", @@ -56,8 +56,5 @@ "platform": { "php": ">=7.0.0" }, - "platform-dev": [], - "platform-overrides": { - "php": "7.0.26" - } + "platform-dev": [] } diff --git a/provider/cake/composer.json b/provider/cake/composer.json index da497b7..2732f82 100644 --- a/provider/cake/composer.json +++ b/provider/cake/composer.json @@ -2,12 +2,7 @@ "require": { "php": ">=7.0.0", "cakephp/orm": "3.5.10", - "cakephp/cache": "^3.5" - }, - "config": { - "platform": { - "php": "7.0.26" - } + "cakephp/cache": "3.5.10" }, "autoload": { "psr-4": { diff --git a/provider/cake/composer.lock b/provider/cake/composer.lock index 6fbeffe..6c09156 100644 --- a/provider/cake/composer.lock +++ b/provider/cake/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "7a1b1a6b5515e7dc8f6bd3d6e2d66a87", + "content-hash": "b867fdffd3f139338acbd8143f16e0aa", "packages": [ { "name": "cakephp/cache", @@ -495,8 +495,5 @@ "platform": { "php": ">=7.0.0" }, - "platform-dev": [], - "platform-overrides": { - "php": "7.0.26" - } + "platform-dev": [] } diff --git a/provider/doctrine/composer.json b/provider/doctrine/composer.json index 3b44f37..2388d09 100644 --- a/provider/doctrine/composer.json +++ b/provider/doctrine/composer.json @@ -5,7 +5,7 @@ }, "config": { "platform": { - "php": "7.0.26" + "php": "7.0.25" } }, "autoload": { diff --git a/provider/doctrine/composer.lock b/provider/doctrine/composer.lock index 2fd397e..6ff5a7f 100644 --- a/provider/doctrine/composer.lock +++ b/provider/doctrine/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "e9f630188dc7debb566bd3a7d53fdf04", + "content-hash": "dcc8b7e57bbe8d5cdc0b33d2aef28f9a", "packages": [ { "name": "doctrine/annotations", @@ -849,6 +849,6 @@ }, "platform-dev": [], "platform-overrides": { - "php": "7.0.26" + "php": "7.0.25" } } diff --git a/provider/eloquent/composer.json b/provider/eloquent/composer.json index ef88933..5a9bc98 100644 --- a/provider/eloquent/composer.json +++ b/provider/eloquent/composer.json @@ -2,12 +2,8 @@ "require": { "php": ">=7.0.0", "illuminate/database": "5.5.28", - "illuminate/events": "5.5.28" - }, - "config": { - "platform": { - "php": "7.0.26" - } + "illuminate/events": "5.5.28", + "doctrine/inflector": "1.2.0" }, "autoload": { "psr-4": { diff --git a/provider/eloquent/composer.lock b/provider/eloquent/composer.lock index 80b3d3a..e9b6c04 100644 --- a/provider/eloquent/composer.lock +++ b/provider/eloquent/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "0cb27bfebe1905ae42d3f22ae6ebea14", + "content-hash": "f80739c73982618eb8e2755f1a4d0adf", "packages": [ { "name": "doctrine/inflector", @@ -609,8 +609,5 @@ "platform": { "php": ">=7.0.0" }, - "platform-dev": [], - "platform-overrides": { - "php": "7.0.26" - } + "platform-dev": [] } diff --git a/provider/phalcon/composer.json b/provider/phalcon/composer.json index 32f8f54..8aab1f6 100644 --- a/provider/phalcon/composer.json +++ b/provider/phalcon/composer.json @@ -1,12 +1,7 @@ { "require": { "php": ">=7.0.0", - "ext-phalcon": ">=3.2.0" - }, - "config": { - "platform": { - "php": "7.0.26" - } + "ext-phalcon": ">=3.3.0" }, "autoload": { "psr-4": { diff --git a/provider/phalcon/composer.lock b/provider/phalcon/composer.lock new file mode 100644 index 0000000..ccb74aa --- /dev/null +++ b/provider/phalcon/composer.lock @@ -0,0 +1,20 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "60c83bcbc861bf8156596593c4304d56", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=7.0.0", + "ext-phalcon": ">=3.3.0" + }, + "platform-dev": [] +} diff --git a/provider/propel/Models/Base/Comments.php b/provider/propel/Models/Base/Comments.php index 258959d..db10038 100644 --- a/provider/propel/Models/Base/Comments.php +++ b/provider/propel/Models/Base/Comments.php @@ -30,7 +30,7 @@ abstract class Comments implements ActiveRecordInterface /** * TableMap class name */ - const TABLE_MAP = '\\OrmBench\\Models\\Propel\\Map\\CommentsTableMap'; + const TABLE_MAP = '\\OrmBench\\Propel\\Models\\Map\\CommentsTableMap'; /** @@ -547,7 +547,7 @@ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = Ta return $startcol + 5; // 5 = CommentsTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException(sprintf('Error populating %s object', '\\OrmBench\\Models\\Propel\\Comments'), 0, $e); + throw new PropelException(sprintf('Error populating %s object', '\\OrmBench\\Propel\\Models\\Comments'), 0, $e); } } diff --git a/provider/propel/Models/Base/CommentsQuery.php b/provider/propel/Models/Base/CommentsQuery.php index f6b5fc9..23c593b 100644 --- a/provider/propel/Models/Base/CommentsQuery.php +++ b/provider/propel/Models/Base/CommentsQuery.php @@ -88,7 +88,7 @@ abstract class CommentsQuery extends ModelCriteria * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'default', $modelName = '\\OrmBench\\Models\\Propel\\Comments', $modelAlias = null) + public function __construct($dbName = 'default', $modelName = '\\OrmBench\\Propel\\Models\\Comments', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } diff --git a/provider/propel/Models/Base/Posts.php b/provider/propel/Models/Base/Posts.php index 35c1b6b..a4c5822 100644 --- a/provider/propel/Models/Base/Posts.php +++ b/provider/propel/Models/Base/Posts.php @@ -33,7 +33,7 @@ abstract class Posts implements ActiveRecordInterface /** * TableMap class name */ - const TABLE_MAP = '\\OrmBench\\Models\\Propel\\Map\\PostsTableMap'; + const TABLE_MAP = '\\OrmBench\\Propel\\Models\\Map\\PostsTableMap'; /** @@ -553,7 +553,7 @@ public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = Ta return $startcol + 5; // 5 = PostsTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { - throw new PropelException(sprintf('Error populating %s object', '\\OrmBench\\Models\\Propel\\Posts'), 0, $e); + throw new PropelException(sprintf('Error populating %s object', '\\OrmBench\\Propel\\Models\\Posts'), 0, $e); } } diff --git a/provider/propel/Models/Base/PostsQuery.php b/provider/propel/Models/Base/PostsQuery.php index 845a59a..d168b81 100644 --- a/provider/propel/Models/Base/PostsQuery.php +++ b/provider/propel/Models/Base/PostsQuery.php @@ -88,7 +88,7 @@ abstract class PostsQuery extends ModelCriteria * @param string $modelName The phpName of a model, e.g. 'Book' * @param string $modelAlias The alias for the model in this query, e.g. 'b' */ - public function __construct($dbName = 'default', $modelName = '\\OrmBench\\Models\\Propel\\Posts', $modelAlias = null) + public function __construct($dbName = 'default', $modelName = '\\OrmBench\\Propel\\Models\\Posts', $modelAlias = null) { parent::__construct($dbName, $modelName, $modelAlias); } diff --git a/provider/propel/Models/Map/CommentsTableMap.php b/provider/propel/Models/Map/CommentsTableMap.php index 1e71873..5ae9157 100644 --- a/provider/propel/Models/Map/CommentsTableMap.php +++ b/provider/propel/Models/Map/CommentsTableMap.php @@ -37,7 +37,7 @@ class CommentsTableMap extends TableMap /** * The related Propel class for this table */ - const OM_CLASS = '\\OrmBench\\Models\\Propel\\Comments'; + const OM_CLASS = '\\OrmBench\\Propel\\Models\\Comments'; /** * A class that can be returned by this tableMap @@ -130,7 +130,7 @@ public function initialize() $this->setName('comments'); $this->setPhpName('Comments'); $this->setIdentifierQuoting(false); - $this->setClassName('\\OrmBench\\Models\\Propel\\Comments'); + $this->setClassName('\\OrmBench\\Propel\\Models\\Comments'); $this->setPackage('OrmBench.Models.Propel'); $this->setUseIdGenerator(true); // columns @@ -146,7 +146,7 @@ public function initialize() */ public function buildRelations() { - $this->addRelation('Posts', '\\OrmBench\\Models\\Propel\\Posts', RelationMap::MANY_TO_ONE, array ( + $this->addRelation('Posts', '\\OrmBench\\Propel\\Models\\Posts', RelationMap::MANY_TO_ONE, array ( 0 => array ( 0 => ':post_id', diff --git a/provider/propel/Models/Map/PostsTableMap.php b/provider/propel/Models/Map/PostsTableMap.php index 6fbc2ef..da9ecfa 100644 --- a/provider/propel/Models/Map/PostsTableMap.php +++ b/provider/propel/Models/Map/PostsTableMap.php @@ -37,7 +37,7 @@ class PostsTableMap extends TableMap /** * The related Propel class for this table */ - const OM_CLASS = '\\OrmBench\\Models\\Propel\\Posts'; + const OM_CLASS = '\\OrmBench\\Propel\\Models\\Posts'; /** * A class that can be returned by this tableMap @@ -130,7 +130,7 @@ public function initialize() $this->setName('posts'); $this->setPhpName('Posts'); $this->setIdentifierQuoting(false); - $this->setClassName('\\OrmBench\\Models\\Propel\\Posts'); + $this->setClassName('\\OrmBench\\Propel\\Models\\Posts'); $this->setPackage('OrmBench.Models.Propel'); $this->setUseIdGenerator(true); // columns @@ -146,14 +146,18 @@ public function initialize() */ public function buildRelations() { - $this->addRelation('Comments', '\\OrmBench\\Models\\Propel\\Comments', RelationMap::ONE_TO_MANY, array ( - 0 => - array ( - 0 => ':post_id', - 1 => ':id', - ), -), 'CASCADE', null, 'Commentss', false); - } // buildRelations() + $this->addRelation( + 'Comments', + '\\OrmBench\\Propel\\Models\\Comments', + RelationMap::ONE_TO_MANY, + [[':post_id', ':id']], + 'CASCADE', + null, + 'Commentss', + false + ); + } + /** * Method to invalidate the instance pool of all tables related to posts * by a foreign key with ON DELETE CASCADE */ diff --git a/provider/propel/composer.json b/provider/propel/composer.json index 85cd697..616ce09 100644 --- a/provider/propel/composer.json +++ b/provider/propel/composer.json @@ -5,7 +5,7 @@ }, "config": { "platform": { - "php": "7.0.26" + "php": "7.0.25" } }, "autoload": { diff --git a/provider/propel/composer.lock b/provider/propel/composer.lock index 9e7d53a..bfcaa4f 100644 --- a/provider/propel/composer.lock +++ b/provider/propel/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "fbf0798698f0426a3bda1ebde809528b", + "content-hash": "3c8053fe9f3a9acd65cf84b0aa842f35", "packages": [ { "name": "propel/propel", @@ -686,6 +686,6 @@ }, "platform-dev": [], "platform-overrides": { - "php": "7.0.26" + "php": "7.0.25" } } diff --git a/provider/yii/composer.json b/provider/yii/composer.json index ff31f12..d098f36 100644 --- a/provider/yii/composer.json +++ b/provider/yii/composer.json @@ -9,11 +9,6 @@ "bower-asset/punycode": "*", "bower-asset/inputmask": "*" }, - "config": { - "platform": { - "php": "7.0.26" - } - }, "autoload": { "psr-4": { "OrmBench\\Yii\\": "./" diff --git a/provider/yii/composer.lock b/provider/yii/composer.lock index 1c638e6..201e040 100644 --- a/provider/yii/composer.lock +++ b/provider/yii/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "e8379e3efd764bdc72a10c486964ebc3", + "content-hash": "79c9f80dba27643b9c50bb7364178ebc", "packages": [ { "name": "cebe/markdown", @@ -273,8 +273,5 @@ "platform": { "php": ">=7.0.0" }, - "platform-dev": [], - "platform-overrides": { - "php": "7.0.26" - } + "platform-dev": [] } diff --git a/run b/run index a251246..ea7f9e2 100755 --- a/run +++ b/run @@ -28,11 +28,14 @@ try { Bootstrap::init($arguments[0], $arguments[1], $arguments[2], (bool) $arguments[3]); } catch (\AssertionError $e) { fprintf(STDERR, "Assertion error for: %s on %s:%d\n", $e->getMessage(), $e->getFile(), $e->getLine()); + exit(1); } catch(\BadMethodCallException $e) { fprintf(STDERR, "%s\n", $e->getMessage()); + exit(1); } catch (\Throwable $e) { fprintf(STDERR, "%s: %s on %s:%d\n", get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()); fprintf(STDERR, "%s\n", $e->getTraceAsString()); + exit(1); } $template =<<set_model_directory(DOCROOT . '/src/Models/Activerecord'); + $configurator->set_model_directory(DOCROOT . '/provider/activerecord/Models'); $configurator->set_connections([ 'development' => $config['dsn'], ]); diff --git a/src/Provider/Propel.php b/src/Provider/Propel.php index 8eaec66..0109cb2 100644 --- a/src/Provider/Propel.php +++ b/src/Provider/Propel.php @@ -11,14 +11,14 @@ class Propel extends AbstractProvider { public function setUp() { - require_once DOCROOT . '/config/propel.php'; + $config = require_once DOCROOT . '/config/propel.php'; $serviceContainer = PropelRuntime::getServiceContainer(); $serviceContainer->checkVersion('2.0.0-dev'); $serviceContainer->setAdapterClass('default', 'mysql'); $manager = new ConnectionManagerSingle(); - $manager->setConfiguration(require DOCROOT . '/config/propel.php'); + $manager->setConfiguration($config); $manager->setName('default'); $serviceContainer->setConnectionManager('default', $manager);