diff --git a/builder/gen-dockerfile/src/Builder/Exception/GoogleCloudVersionException.php b/builder/gen-dockerfile/src/Builder/Exception/GoogleCloudVersionException.php deleted file mode 100644 index a58155c3..00000000 --- a/builder/gen-dockerfile/src/Builder/Exception/GoogleCloudVersionException.php +++ /dev/null @@ -1,22 +0,0 @@ -workspace); - if ($result == ValidateGoogleCloud::FOUND_GOOGLE_CLOUD) { - $enableStackdriverCmd = 'RUN /bin/bash /stackdriver-files/' - . 'enable_stackdriver_integration.sh'; - } else { - $enableStackdriverCmd = 'RUN /bin/bash /stackdriver-files/' - . 'enable_stackdriver_integration.sh --individual'; - } + $enableStackdriverCmd = 'RUN /bin/bash /stackdriver-files/' + . 'enable_stackdriver_integration.sh'; } else { $enableStackdriverCmd = ''; } diff --git a/builder/gen-dockerfile/src/ValidateGoogleCloud.php b/builder/gen-dockerfile/src/ValidateGoogleCloud.php deleted file mode 100644 index 7d4dfcfd..00000000 --- a/builder/gen-dockerfile/src/ValidateGoogleCloud.php +++ /dev/null @@ -1,143 +0,0 @@ - self::MINIMUM_GOOGLE_CLOUD_VERSION, - 'google/cloud-logging' => self::MINIMUM_GOOGLE_LOGGING_VERSION, - 'google/cloud-error-reporting' => self::MINIMUM_GOOGLE_ER_VERSION - ]; - // Make sure there is `require` field in `composer.json`. - if (!(is_array($composer) && array_key_exists('require', $composer))) { - throw new GoogleCloudVersionException( - 'Required packages not found in composer.json. ' - . 'Consider running `composer require google/cloud`' - ); - } - // For google/cloud. - if (array_key_exists('google/cloud', $composer['require'])) { - $constraintsMap['google/cloud'] = - $composer['require']['google/cloud']; - } elseif (array_key_exists('google/cloud-logging', - $composer['require']) && - array_key_exists('google/cloud-error-reporting', - $composer['require'])) { - // For cloud-logging and cloud-error-reporting. - $constraintsMap['google/cloud-logging'] = - $composer['require']['google/cloud-logging']; - $constraintsMap['google/cloud-error-reporting'] = - $composer['require']['google/cloud-error-reporting']; - } else { - throw new GoogleCloudVersionException( - 'Required packages not found in composer.json. ' - . 'Consider running `composer require google/cloud`' - ); - } - - // Now we have $constraintsMap. All should have at least the minimum - // version. - - foreach ($constraintsMap as $package => $constraints) { - $versions = self::getCurrentPackageVersions($package); - - // Check all the available versions against the constraints - // and returns matched ones - $filtered = Semver::satisfiedBy($versions, $constraints); - if (count($filtered) === 0) { - throw new GoogleCloudVersionException( - "no available matching version of $package" - ); - } - $found = false; - foreach ($filtered as $version) { - if (Comparator::greaterThanOrEqualTo($version, $minimumVersionMap[$package])) { - $found = true; - break; - } - } - if ($found === false) { - throw new GoogleCloudVersionException( - "stackdriver integration needs $package " - . $minimumVersionMap[$package] . ' or higher' - ); - } - } - - if (array_key_exists('google/cloud', $constraintsMap)) { - return self::FOUND_GOOGLE_CLOUD; - } else { - return self::FOUND_INDIVIDUAL_PACKAGES; - } - } - - /** - * Determine available versions for a given package. - * @param string $package - * @return array - */ - private static function getCurrentPackageVersions($package) - { - exec( - "composer show --all $package |grep 'versions : '", - $output, - $ret - ); - if ($ret !== 0) { - throw new GoogleCloudVersionException( - "Failed to determine available versions of $package package" - ); - } - // Remove the title - $output = substr($output[0], strlen('versions : ')); - - // Split the version strings - $versions = preg_split('/[,\s]+/', $output); - - // Remove '*', indicator for the latest stable - $versions = array_diff($versions, ['*']); - return $versions; - } -} diff --git a/builder/gen-dockerfile/tests/GenFilesCommandTest.php b/builder/gen-dockerfile/tests/GenFilesCommandTest.php index feaee36a..7bff7e02 100644 --- a/builder/gen-dockerfile/tests/GenFilesCommandTest.php +++ b/builder/gen-dockerfile/tests/GenFilesCommandTest.php @@ -187,106 +187,6 @@ public function dataProvider() [], '\\Google\\Cloud\\Runtimes\\Builder\\Exception\\InvalidComposerFlagsException' ], - [ - // stackdriver simple case - __DIR__ . '/test_data/stackdriver_simple', - null, - '', - '/app/web', - 'added by the php runtime builder', - 'gcr.io/google-appengine/php72:latest', - ["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n", - "FRONT_CONTROLLER_FILE='index.php' \\\n", - "DETECTED_PHP_VERSION='7.2' \\\n", - "IS_BATCH_DAEMON_RUNNING='true' \n", - "enable_stackdriver_integration.sh" - ] - ], - [ - // stackdriver wildcard dep - __DIR__ . '/test_data/stackdriver_wildcard', - null, - '', - '/app/web', - 'added by the php runtime builder', - 'gcr.io/google-appengine/php72:latest', - ["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n", - "FRONT_CONTROLLER_FILE='index.php' \\\n", - "DETECTED_PHP_VERSION='7.2' \\\n", - "IS_BATCH_DAEMON_RUNNING='true' \n", - "enable_stackdriver_integration.sh" - ] - ], - [ - // stackdriver individual packages - __DIR__ . '/test_data/stackdriver_individual', - null, - '', - '/app/web', - 'added by the php runtime builder', - 'gcr.io/google-appengine/php72:latest', - ["COMPOSER_FLAGS='--no-dev --prefer-dist' \\\n", - "FRONT_CONTROLLER_FILE='index.php' \\\n", - "DETECTED_PHP_VERSION='7.2' \\\n", - "IS_BATCH_DAEMON_RUNNING='true' \n", - "enable_stackdriver_integration.sh --individual" - ] - ], - [ - // stackdriver old logging - __DIR__ . '/test_data/stackdriver_old_logging', - null, - '', - '/app/web', - 'added by the php runtime builder', - 'gcr.io/google-appengine/php72:latest', - [], - '\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException' - ], - [ - // stackdriver old error_reporting - __DIR__ . '/test_data/stackdriver_old_er', - null, - '', - '/app/web', - 'added by the php runtime builder', - 'gcr.io/google-appengine/php72:latest', - [], - '\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException' - ], - [ - // stackdriver no composer.json - __DIR__ . '/test_data/stackdriver_no_composer', - null, - '', - '/app/web', - 'added by the php runtime builder', - 'gcr.io/google-appengine/php72:latest', - [], - '\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException' - ], - [ - // stackdriver no google/cloud - __DIR__ . '/test_data/stackdriver_no_google_cloud', - null, - '', - '/app/web', - 'added by the php runtime builder', - 'gcr.io/google-appengine/php72:latest', - [], - '\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException' - ], - [ - // stackdriver old google/cloud - __DIR__ . '/test_data/stackdriver_old_google_cloud', - null, - '', - '/app/web', - 'added by the php runtime builder', - 'gcr.io/google-appengine/php72:latest', - [], - '\\Google\\Cloud\\Runtimes\\Builder\\Exception\\GoogleCloudVersionException' - ], [ // PHP 5.6 __DIR__ . '/test_data/php56', diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_individual/app.yaml b/builder/gen-dockerfile/tests/test_data/stackdriver_individual/app.yaml deleted file mode 100644 index 383f6885..00000000 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_individual/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -env: flex -runtime: php - -runtime_config: - enable_stackdriver_integration: true - document_root: web diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_no_composer/app.yaml b/builder/gen-dockerfile/tests/test_data/stackdriver_no_composer/app.yaml deleted file mode 100644 index 383f6885..00000000 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_no_composer/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -env: flex -runtime: php - -runtime_config: - enable_stackdriver_integration: true - document_root: web diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_no_google_cloud/app.yaml b/builder/gen-dockerfile/tests/test_data/stackdriver_no_google_cloud/app.yaml deleted file mode 100644 index 383f6885..00000000 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_no_google_cloud/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -env: flex -runtime: php - -runtime_config: - enable_stackdriver_integration: true - document_root: web diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_old_er/app.yaml b/builder/gen-dockerfile/tests/test_data/stackdriver_old_er/app.yaml deleted file mode 100644 index 383f6885..00000000 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_old_er/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -env: flex -runtime: php - -runtime_config: - enable_stackdriver_integration: true - document_root: web diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_old_google_cloud/app.yaml b/builder/gen-dockerfile/tests/test_data/stackdriver_old_google_cloud/app.yaml deleted file mode 100644 index 383f6885..00000000 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_old_google_cloud/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -env: flex -runtime: php - -runtime_config: - enable_stackdriver_integration: true - document_root: web diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_old_logging/app.yaml b/builder/gen-dockerfile/tests/test_data/stackdriver_old_logging/app.yaml deleted file mode 100644 index 383f6885..00000000 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_old_logging/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -env: flex -runtime: php - -runtime_config: - enable_stackdriver_integration: true - document_root: web diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_simple/app.yaml b/builder/gen-dockerfile/tests/test_data/stackdriver_simple/app.yaml deleted file mode 100644 index 383f6885..00000000 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_simple/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -env: flex -runtime: php - -runtime_config: - enable_stackdriver_integration: true - document_root: web diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_wildcard/app.yaml b/builder/gen-dockerfile/tests/test_data/stackdriver_wildcard/app.yaml deleted file mode 100644 index 383f6885..00000000 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_wildcard/app.yaml +++ /dev/null @@ -1,6 +0,0 @@ -env: flex -runtime: php - -runtime_config: - enable_stackdriver_integration: true - document_root: web diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 03094c65..5fe9a0f6 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -67,6 +67,13 @@ steps: waitFor: ['php56'] id: test-runner + # base tests + - name: gcr.io/cloud-builders/docker + args: ['run', '-v', '/workspace/php-base:/workspace', 'gcr.io/${_GOOGLE_PROJECT_ID}/php-test-runner:$_TAG'] + waitFor: ['-'] + id: php-base-tests + waitFor: ['test-runner', 'php-base'] + # php-onbuild - name: gcr.io/cloud-builders/docker args: ['build', '-t', 'gcr.io/${_GOOGLE_PROJECT_ID}/php:$_TAG', '.'] diff --git a/php-base/build-scripts/detect_php_version.php b/php-base/build-scripts/detect_php_version.php index 19e81f95..fdc8664e 100644 --- a/php-base/build-scripts/detect_php_version.php +++ b/php-base/build-scripts/detect_php_version.php @@ -14,70 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require_once __DIR__ . '/vendor/autoload.php'; - -use Composer\Semver\Semver; - -class ExactVersionException extends Exception -{ -} - -class NoSpecifiedVersionException extends Exception -{ - public function __construct() - { - parent::__construct("No version found in composer.json"); - } -} - -class InvalidVersionException extends Exception -{ - public function __construct($constraint, $availableVersions) - { - parent::__construct("No suitable version for for '$constraint' in ${implode(',', $availableVersions)}"); - } -} - -class DetectPhpVersion -{ - public static function versionFromComposer($filename, $availableVersions = null) - { - $composer = json_decode(file_get_contents($filename), true); - if (is_array($composer) - && array_key_exists('require', $composer) - && array_key_exists('php', $composer['require'])) { - $constraints = $composer['require']['php']; - return self::version($constraints, $availableVersions); - } - throw new NoSpecifiedVersionException(); - } - public static function version($constraint, $availableVersions = null) - { - if (preg_match('/^\d+\.\d+\.\d+$/', $constraint)) { - throw new ExactVersionException(); - } - - $availableVersions = $availableVersions ?: self::detectAvailableVersions(); - foreach ($availableVersions as $version) { - if (Semver::satisfies($version, $constraint)) { - // The first match wins, picking the highest version possible. - return $version; - } - } - throw new InvalidVersionException($constraint, $availableVersions); - } - - private static function detectAvailableVersions() - { - return [ - trim(file_get_contents('/opt/php72_version')), - trim(file_get_contents('/opt/php71_version')), - trim(file_get_contents('/opt/php70_version')), - trim(file_get_contents('/opt/php56_version')) - ]; - } -} +require_once __DIR__ . '/vendor/autoload.php'; +require_once __DIR__ . '/src/DetectPhpVersion.php'; if (basename($argv[0]) == basename(__FILE__)) { if (count($argv) < 2) { diff --git a/php-base/build-scripts/install_extensions.php b/php-base/build-scripts/install_extensions.php index 75923768..88a8ead4 100644 --- a/php-base/build-scripts/install_extensions.php +++ b/php-base/build-scripts/install_extensions.php @@ -15,206 +15,7 @@ * limitations under the License. */ -class InstallExtensions -{ - const AVAILABLE_EXTENSIONS = [ - 'bcmath', - 'calendar', - 'exif', - 'ftp', - 'gd', - 'gettext', - 'intl', - 'mbstring', - 'mysql', - 'shmop', - 'soap', - 'sqlite3', - 'pdo_sqlite', - 'xmlrpc', - 'xsl', - ## Debian package extensions below - 'cassandra', - 'ev', - 'event', - 'grpc', - 'imagick', - 'mailparse', - 'memcache', - 'memcached', - 'mongodb', - 'oauth', - 'opencensus', - 'phalcon', - 'pq', - 'protobuf', - 'raphf', - 'rdkafka', - 'redis', - 'stackdriver_debugger' - ]; - const AVAILABLE_EXTENSIONS_TO_INSTALL = [ - 'amqp', - 'apm', - 'bitset', - 'couchbase', - 'ds', - 'eio', - 'hprose', - 'igbinary', - 'jsond', - 'krb5', - 'lua', - 'lzf', - 'memprof', - 'mongo', - 'seaslog', - 'stomp', - 'swoole', - 'sync', - 'tcpwrap', - 'timezonedb', - 'v8js', - 'vips', - 'yaconf', - 'yaf', - 'yaml' - ]; - const UNAVAILABLE_EXTENSIONS = [ - 'apm' => ['5.6'], - 'couchbase' => ['5.6'], - 'ds' => ['5.6'], - 'lua' => ['5.6'], - 'memcache' => ['7.0', '7.1', '7.2'], - 'mongo' => ['7.0', '7.1', '7.2'], - 'opencensus' => ['5.6'], - 'phalcon' => ['7.1', '7.2'], - 'stackdriver_debugger' => ['5.6'], - 'v8js' => ['5.6'], - 'vips' => ['5.6'], - 'yaconf' => ['5.6'] - ]; - - private $extensions = []; - private $extensionsToInstall = []; - private $phpVersion; - private $configFile; - private $errors = []; - - public function __construct($filename, $configFile = null, $phpVersion = null) - { - $this->phpVersion = $phpVersion; - $this->configFile = $configFile ?: $this->defaultConfigFile(); - $composer = json_decode(file_get_contents($filename), true); - if (is_array($composer) && array_key_exists('require', $composer)) { - foreach ($composer['require'] as $package => $version) { - if (substr($package, 0, 4) == 'ext-') { - $this->addExtension(substr($package, 4), $version); - } - } - } - } - - public function extensions() - { - return $this->extensions; - } - - public function errors() - { - return $this->errors; - } - - public function installExtensions() - { - // If there are errors, then bail out - if (!empty($this->errors)) { - return false; - } - - // Nothing to do - if (empty($this->extensions)) { - return true; - } - - // Install any new debian packages - $this->installPackages(); - - // Write a custom php.ini file that enables each extension - $this->writeConfigFile(); - - return true; - } - - public function packageName($extension) - { - return 'gcp-php' . str_replace('.', '', $this->phpVersion) . '-' . $extension; - } - - private function defaultConfigFile() - { - return implode([ - getenv('PHP_DIR'), - 'lib', - 'conf.d', - 'extensions.ini' - ], '/'); - } - - private function installPackages() - { - system('apt-get -y update'); - $command = 'apt-get install -y --no-install-recommends ' - . implode(array_map([$this, 'packageName'], $this->extensionsToInstall), ' '); - echo $command . PHP_EOL; - system($command); - } - - private function writeConfigFile() - { - $fp = fopen($this->configFile, 'a'); - foreach ($this->extensions as $extension) { - fwrite($fp, "extension=$extension.so" . PHP_EOL); - } - fclose($fp); - } - - private function addExtension($package, $version) - { - // If it's already loaded, no need for activation - if (extension_loaded($package)) { - return; - } - - // See if we support the package at all - if (!in_array($package, self::AVAILABLE_EXTENSIONS) && - !in_array($package, self::AVAILABLE_EXTENSIONS_TO_INSTALL)) { - $this->errors[] = "- $package $version is not available on your system."; - return; - } - - // Disallow any specific version pinning - if ($version != '*') { - $this->errors[] = "- $package is available, but version must be specified as \"*\" in your composer.json"; - return; - } - - // Check against our blacklist of php version/extension combinations - if (array_key_exists($package, self::UNAVAILABLE_EXTENSIONS) && - in_array($this->phpVersion, self::UNAVAILABLE_EXTENSIONS[$package])) { - $this->errors[] = "- $package is available, but not on php version {$this->phpVersion}"; - return; - } - - // We can install this extension - $this->extensions[] = $package; - - // See if we need to install the debian package - if (in_array($package, self::AVAILABLE_EXTENSIONS_TO_INSTALL)) { - $this->extensionsToInstall[] = $package; - } - } -} +require_once __DIR__ . '/src/InstallExtensions.php'; if (basename($argv[0]) == basename(__FILE__)) { if (count($argv) < 2) { diff --git a/php-base/build-scripts/src/DetectPhpVersion.php b/php-base/build-scripts/src/DetectPhpVersion.php new file mode 100644 index 00000000..2400e750 --- /dev/null +++ b/php-base/build-scripts/src/DetectPhpVersion.php @@ -0,0 +1,80 @@ + ['5.6'], + 'couchbase' => ['5.6'], + 'ds' => ['5.6'], + 'lua' => ['5.6'], + 'memcache' => ['7.0', '7.1', '7.2'], + 'mongo' => ['7.0', '7.1', '7.2'], + 'opencensus' => ['5.6'], + 'phalcon' => ['7.1', '7.2'], + 'stackdriver_debugger' => ['5.6'], + 'v8js' => ['5.6'], + 'vips' => ['5.6'], + 'yaconf' => ['5.6'] + ]; + + private $extensions = []; + private $extensionsToInstall = []; + private $phpVersion; + private $configFile; + private $errors = []; + + public function __construct($filename, $configFile = null, $phpVersion = null) + { + $this->phpVersion = $phpVersion; + $this->configFile = $configFile ?: $this->defaultConfigFile(); + $composer = json_decode(file_get_contents($filename), true); + if (is_array($composer) && array_key_exists('require', $composer)) { + foreach ($composer['require'] as $package => $version) { + if (substr($package, 0, 4) == 'ext-') { + $this->addExtension(substr($package, 4), $version); + } + } + } + } + + public function extensions() + { + return $this->extensions; + } + + public function errors() + { + return $this->errors; + } + + public function installExtensions() + { + // If there are errors, then bail out + if (!empty($this->errors)) { + return false; + } + + // Nothing to do + if (empty($this->extensions)) { + return true; + } + + // Install any new debian packages + $this->installPackages(); + + // Write a custom php.ini file that enables each extension + $this->writeConfigFile(); + + return true; + } + + public function packageName($extension) + { + return 'gcp-php' . str_replace('.', '', $this->phpVersion) . '-' . $extension; + } + + private function defaultConfigFile() + { + return implode([ + getenv('PHP_DIR'), + 'lib', + 'conf.d', + 'extensions.ini' + ], '/'); + } + + private function installPackages() + { + system('apt-get -y update'); + $command = 'apt-get install -y --no-install-recommends ' + . implode(array_map([$this, 'packageName'], $this->extensionsToInstall), ' '); + echo $command . PHP_EOL; + system($command); + } + + private function writeConfigFile() + { + $fp = fopen($this->configFile, 'a'); + foreach ($this->extensions as $extension) { + fwrite($fp, "extension=$extension.so" . PHP_EOL); + } + fclose($fp); + } + + private function addExtension($package, $version) + { + // If it's already loaded, no need for activation + if (extension_loaded($package)) { + return; + } + + // See if we support the package at all + if (!in_array($package, self::AVAILABLE_EXTENSIONS) && + !in_array($package, self::AVAILABLE_EXTENSIONS_TO_INSTALL)) { + $this->errors[] = "- $package $version is not available on your system."; + return; + } + + // Disallow any specific version pinning + if ($version != '*') { + $this->errors[] = "- $package is available, but version must be specified as \"*\" in your composer.json"; + return; + } + + // Check against our blacklist of php version/extension combinations + if (array_key_exists($package, self::UNAVAILABLE_EXTENSIONS) && + in_array($this->phpVersion, self::UNAVAILABLE_EXTENSIONS[$package])) { + $this->errors[] = "- $package is available, but not on php version {$this->phpVersion}"; + return; + } + + // We can install this extension + $this->extensions[] = $package; + + // See if we need to install the debian package + if (in_array($package, self::AVAILABLE_EXTENSIONS_TO_INSTALL)) { + $this->extensionsToInstall[] = $package; + } + } +} diff --git a/php-base/stackdriver-files/enable_stackdriver_integration.sh b/php-base/stackdriver-files/enable_stackdriver_integration.sh old mode 100644 new mode 100755 index 9f1e2801..a88639c5 --- a/php-base/stackdriver-files/enable_stackdriver_integration.sh +++ b/php-base/stackdriver-files/enable_stackdriver_integration.sh @@ -28,15 +28,6 @@ echo "Enabling stackdriver integration..." # To start the batch daemon cp /stackdriver-files/batch-daemon.conf /etc/supervisor/conf.d -# Detect the stackdriver prepend path -set +e -PREPEND_PATH=`php /stackdriver-files/locate_stackdriver_prepend.php` -set -e -if [ $? -ne 0 ]; then - if [ "${1}" = "--individual" ]; then - PREPEND_PATH="/app/vendor/google/cloud-error-reporting/prepend.php" - else - PREPEND_PATH="/app/vendor/google/cloud/src/ErrorReporting/prepend.php" - fi -fi -echo "auto_prepend_file=$PREPEND_PATH" > ${PHP_DIR}/lib/conf.d/stackdriver-prepend.ini +php /stackdriver-files/enable_stackdriver_prepend.php \ + -a ${APP_DIR} + -o ${PHP_DIR}/lib/conf.d/stackdriver-prepend.ini diff --git a/php-base/stackdriver-files/enable_stackdriver_prepend.php b/php-base/stackdriver-files/enable_stackdriver_prepend.php new file mode 100644 index 00000000..3f72838d --- /dev/null +++ b/php-base/stackdriver-files/enable_stackdriver_prepend.php @@ -0,0 +1,48 @@ + '/app', + 'o' => 'php://stdout' +]; + +$autoload = $options['a'] . '/vendor/autoload.php'; +if (file_exists($autoload)) { + require_once $autoload; +} +require_once __DIR__ . '/stackdriver_integration.php'; + +$integration = new StackdriverIntegration(); + +try { + $location = $integration->prependFileLocation(); + $fp = fopen($options['o'], 'w'); + if ($fp === false) { + throw new RuntimeException(sprintf('Failed opening file %s for writing.', $options['o'])); + } + try { + $ret = fwrite($fp, 'auto_prepend_file=' . $location . PHP_EOL); + if ($ret === false) { + throw new RuntimeException(sprintf('Failed writing to file: %s', $options['o'])); + } + } finally { + fclose($fp); + } +} catch (Exception $e) { + echo $e->getMessage(); + exit(1); +} diff --git a/php-base/stackdriver-files/locate_stackdriver_prepend.php b/php-base/stackdriver-files/locate_stackdriver_prepend.php deleted file mode 100644 index 931b03c1..00000000 --- a/php-base/stackdriver-files/locate_stackdriver_prepend.php +++ /dev/null @@ -1,36 +0,0 @@ -hasMethod('prependFileLocation')) { - echo Bootstrap::prependFileLocation() . PHP_EOL; - } else { - // default to same directory as the Bootstrap.php - echo realpath(dirname($reflection->getFileName()) . '/prepend.php') . PHP_EOL; - } -} else { - die('cannot find ErrorReporting\Bootstrap class'); -} diff --git a/php-base/stackdriver-files/stackdriver_integration.php b/php-base/stackdriver-files/stackdriver_integration.php new file mode 100644 index 00000000..677fcb47 --- /dev/null +++ b/php-base/stackdriver-files/stackdriver_integration.php @@ -0,0 +1,94 @@ +validErrorReportingVersion()) { + throw new Exception('You must include either google/cloud >= 0.33.0 or google/error-reporting >= 0.4.0'); + } + + if (!$this->validLoggingVersion()) { + throw new Exception('You must include either google/cloud >= 0.33.0 or google/logging >= 1.3.0'); + } + + $file = null; + $reflection = new \ReflectionClass(Bootstrap::class); + if ($reflection->hasMethod('prependFileLocation')) { + $file = Bootstrap::prependFileLocation(); + } else { + // default to same directory as the Bootstrap.php + $file = realpath(dirname($reflection->getFileName()) . '/prepend.php'); + } + + if (!file_exists($file)) { + throw new Exception(sprintf('expected file %s to exist', $file)); + } + + return $file; + } + + /** + * Returns whether or not the ErrorReporting version is high enough. + * + * @return bool + */ + public function validErrorReportingVersion() + { + // Any version that has the `Bootstrap` class is considered high enough + return class_exists(Bootstrap::class); + } + + /** + * Returns whether or not the Logging version is high enough. + * + * @return bool + */ + public function validLoggingVersion() + { + if (!class_exists(LoggingClient::class)) { + return false; + } + list($major, $minor, $patch) = explode('.', LoggingClient::VERSION); + $major = (int) $major; + $minor = (int) $minor; + return $major > 1 || ($major == 1 && $minor >= 3); + } +} diff --git a/php-base/tests/DetectPhpVersionTest.php b/php-base/tests/DetectPhpVersionTest.php index 2240cf7d..fab8c3f3 100644 --- a/php-base/tests/DetectPhpVersionTest.php +++ b/php-base/tests/DetectPhpVersionTest.php @@ -17,7 +17,7 @@ use PHPUnit\Framework\TestCase; -require_once(__DIR__ . "/../build-scripts/detect_php_version.php"); +require_once(__DIR__ . "/../build-scripts/src/DetectPhpVersion.php"); class DetectPhpVersionTest extends TestCase { @@ -42,10 +42,20 @@ public function testDetectsHighestVersion() $this->assertEquals(self::PHP_71, $version); } - public function testFailureReturnsEmptyString() + /** + * @expectedException \ExactVersionException + */ + public function testExactVersionDirect() + { + $version = DetectPhpVersion::version('7.1.10', self::AVAILABLE_VERSIONS); + } + + /** + * @expectedException \InvalidVersionException + */ + public function testInvalidVersionDirect() { - $version = DetectPhpVersion::version('7.1.100', self::AVAILABLE_VERSIONS); - $this->assertEquals('', $version); + $version = DetectPhpVersion::version('^7.1.100', self::AVAILABLE_VERSIONS); } /** diff --git a/php-base/tests/InstallExtensionsTest.php b/php-base/tests/InstallExtensionsTest.php index c0ccdada..e0384e77 100644 --- a/php-base/tests/InstallExtensionsTest.php +++ b/php-base/tests/InstallExtensionsTest.php @@ -17,28 +17,28 @@ use PHPUnit\Framework\TestCase; -require_once(__DIR__ . "/../build-scripts/install_extensions.php"); +require_once(__DIR__ . "/../build-scripts/src/InstallExtensions.php"); class InstallExtensionsTest extends TestCase { public function testDetectsPackagedExtensions() { $installer = new InstallExtensions(__DIR__ . '/samples/phalcon.json'); - $this->assertEquals(['phalcon' => '*'], $installer->extensions()); + $this->assertEquals(['phalcon'], $installer->extensions(), implode(',', $installer->errors())); } public function testDetectsSharedExtensions() { $installer = new InstallExtensions(__DIR__ . '/samples/shared.json'); - $this->assertEquals(['mbstring' => '*'], $installer->extensions()); + $this->assertEquals(['sqlite3'], $installer->extensions()); } public function testInstallsExtensions() { $output = tempnam("/tmp", "php.ini"); - $installer = new InstallExtensions(__DIR__ . '/samples/mixed.json', $output); + $installer = new InstallExtensions(__DIR__ . '/samples/shared.json', $output); $this->assertTrue($installer->installExtensions()); - $this->assertEquals("extension=phalcon.so\nextension=mbstring.so\n", file_get_contents($output)); + $this->assertEquals("extension=sqlite3.so\n", file_get_contents($output)); unlink($output); } diff --git a/php-base/tests/StackdriverIntegrationTest.php b/php-base/tests/StackdriverIntegrationTest.php new file mode 100644 index 00000000..12c93774 --- /dev/null +++ b/php-base/tests/StackdriverIntegrationTest.php @@ -0,0 +1,93 @@ +oldpwd = getcwd(); + } + + public function tearDown() + { + chdir($this->oldpwd); + parent::tearDown(); + } + + /** + * @dataProvider validVersions + */ + public function testValidVersions($directory, $expectedFile) + { + $dir = realpath(__DIR__ . '/' . $directory); + exec("cd $dir && composer install --ignore-platform-reqs -q 2>&1", $output, $retVal); + $this->assertEquals(0, $retVal, 'command failed with: ' . implode(';', $output)); + + exec("php stackdriver-files/enable_stackdriver_prepend.php -a $dir", $output, $retVal); + $this->assertEquals(0, $retVal, 'command failed with: ' . implode(';', $output)); + $output = trim(array_pop($output)); + $this->assertStringStartsWith('auto_prepend_file=', $output); + $this->assertStringEndsWith($expectedFile, $output); + } + + public function validVersions() + { + return [ + ['samples/stackdriver_individual', 'vendor/google/cloud-error-reporting/prepend.php'], + ['samples/stackdriver_simple', 'vendor/google/cloud/src/ErrorReporting/prepend.php'], + ['samples/stackdriver_wildcard', 'vendor/google/cloud/ErrorReporting/src/prepend.php'], + ['samples/stackdriver_dev', 'vendor/google/cloud/ErrorReporting/src/prepend.php'], + ]; + } + + /** + * @dataProvider invalidVersions + */ + public function testInvalidVersions($directory) + { + $dir = realpath(__DIR__ . '/' . $directory); + exec("cd $dir && composer install --ignore-platform-reqs -q 2>&1", $output, $retVal); + $this->assertEquals(0, $retVal, 'command failed with: ' . implode(';', $output)); + + exec("php stackdriver-files/enable_stackdriver_prepend.php -a $dir", $output, $retVal); + $this->assertNotEquals(0, $retVal, 'command: ' . implode(';', $output) . ' should have failed.'); + $this->assertContains('You must include', $output[0]); + } + + public function invalidVersions() + { + return [ + ['samples/stackdriver_no_google_cloud'], + ['samples/stackdriver_old_er'], + ['samples/stackdriver_old_google_cloud'], + ['samples/stackdriver_old_logging'] + ]; + } + + public function testNoComposer() + { + $dir = realpath(__DIR__ . '/samples/no_composer'); + exec("php stackdriver-files/enable_stackdriver_prepend.php -a $dir", $output, $retVal); + $this->assertNotEquals(0, $retVal, 'command: ' . implode(';', $output) . ' should have failed.'); + $this->assertContains('You must include', $output[0]); + } +} diff --git a/php-base/tests/bootstrap.php b/php-base/tests/bootstrap.php index b3d9bbc7..6c8c4f51 100644 --- a/php-base/tests/bootstrap.php +++ b/php-base/tests/bootstrap.php @@ -1 +1,3 @@ =5.3.0" + }, + "require-dev": { + "phpunit/phpunit": " 4.8.35" + }, + "type": "library", + "autoload": { + "psr-4": { + "Firebase\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Neuman Vong", + "email": "neuman+pear@twilio.com", + "role": "Developer" + }, + { + "name": "Anant Narayanan", + "email": "anant@php.net", + "role": "Developer" + } + ], + "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", + "homepage": "https://github.com/firebase/php-jwt", + "time": "2017-06-27T22:17:23+00:00" + }, + { + "name": "google/auth", + "version": "v1.3.0", + "source": { + "type": "git", + "url": "https://github.com/google/google-auth-library-php.git", + "reference": "8f7c96146b2c62d3f4c6bbc4b5bb8a8e396b0b71" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/google/google-auth-library-php/zipball/8f7c96146b2c62d3f4c6bbc4b5bb8a8e396b0b71", + "reference": "8f7c96146b2c62d3f4c6bbc4b5bb8a8e396b0b71", + "shasum": "" + }, + "require": { + "firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0", + "guzzlehttp/guzzle": "~5.3.1|~6.0", + "guzzlehttp/psr7": "^1.2", + "php": ">=5.4", + "psr/cache": "^1.0", + "psr/http-message": "^1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^1.11", + "guzzlehttp/promises": "0.1.1|^1.3", + "phpunit/phpunit": "^4.8.36|^5.7", + "sebastian/comparator": ">=1.2.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Auth\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Auth Library for PHP", + "homepage": "http://github.com/google/google-auth-library-php", + "keywords": [ + "Authentication", + "google", + "oauth2" + ], + "time": "2018-04-06T19:26:30+00:00" + }, + { + "name": "google/cloud-core", + "version": "v1.19.2", + "source": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/google-cloud-php-core.git", + "reference": "c0d71125f31400b09d1a1097e6c336f3e2908532" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php-core/zipball/c0d71125f31400b09d1a1097e6c336f3e2908532", + "reference": "c0d71125f31400b09d1a1097e6c336f3e2908532", + "shasum": "" + }, + "require": { + "google/auth": "^1.2", + "guzzlehttp/guzzle": "^5.3|^6.0", + "guzzlehttp/psr7": "^1.2", + "monolog/monolog": "~1", + "php": ">=5.5", + "psr/http-message": "1.0.*", + "rize/uri-template": "~0.3" + }, + "require-dev": { + "erusev/parsedown": "^1.6", + "google/gax": "^0.31.1", + "opis/closure": "^3", + "phpdocumentor/reflection": "^3.0", + "phpunit/phpunit": "^4.8|^5.0", + "squizlabs/php_codesniffer": "2.*" + }, + "suggest": { + "opis/closure": "May be used to serialize closures to process jobs in the batch daemon. Please require version ^3.", + "symfony/lock": "Required for the Spanner cached based session pool. Please require the following commit: 3.3.x-dev#1ba6ac9" + }, + "bin": [ + "bin/google-cloud-batch" + ], + "type": "library", + "extra": { + "component": { + "id": "cloud-core", + "target": "GoogleCloudPlatform/google-cloud-php-core.git", + "path": "Core", + "entry": "src/ServiceBuilder.php" + } + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\Core\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Google Cloud PHP shared dependency, providing functionality useful to all components.", + "time": "2018-04-16T18:09:56+00:00" + }, + { + "name": "google/cloud-error-reporting", + "version": "v0.4.3", + "source": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/google-cloud-php-errorreporting.git", + "reference": "6cf9f760cb3d1d46922611d2682da6b4af12ea00" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php-errorreporting/zipball/6cf9f760cb3d1d46922611d2682da6b4af12ea00", + "reference": "6cf9f760cb3d1d46922611d2682da6b4af12ea00", + "shasum": "" + }, + "require": { + "ext-grpc": "*", + "google/gax": "^0.23.0", + "google/proto-client": "^0.23.0" + }, + "type": "library", + "extra": { + "component": { + "id": "cloud-error-reporting", + "target": "GoogleCloudPlatform/google-cloud-php-errorreporting.git", + "path": "src/ErrorReporting", + "entry": null + } + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\ErrorReporting\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Stackdriver Error Reporting Client for PHP", + "time": "2017-09-05T20:40:19+00:00" + }, + { + "name": "google/cloud-logging", + "version": "v1.4.0", + "source": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/google-cloud-php-logging.git", + "reference": "0a06fcf1c0ead3e5491d3a68ffb0ef1d7b308f93" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/GoogleCloudPlatform/google-cloud-php-logging/zipball/0a06fcf1c0ead3e5491d3a68ffb0ef1d7b308f93", + "reference": "0a06fcf1c0ead3e5491d3a68ffb0ef1d7b308f93", + "shasum": "" + }, + "require": { + "google/cloud-core": "^1.0", + "google/gax": "^0.23", + "google/proto-client": "^0.23" + }, + "type": "library", + "extra": { + "component": { + "id": "cloud-logging", + "target": "GoogleCloudPlatform/google-cloud-php-logging.git", + "path": "src/Logging", + "entry": "LoggingClient.php" + } + }, + "autoload": { + "psr-4": { + "Google\\Cloud\\Logging\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Stackdriver Logging Client for PHP", + "time": "2017-09-12T20:49:36+00:00" + }, + { + "name": "google/gax", + "version": "0.23.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/gax-php.git", + "reference": "e09f219ed50ea1f6162d1945156d2ea6af6cd1f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/gax-php/zipball/e09f219ed50ea1f6162d1945156d2ea6af6cd1f9", + "reference": "e09f219ed50ea1f6162d1945156d2ea6af6cd1f9", + "shasum": "" + }, + "require": { + "google/auth": "~0.9|^1.0", + "google/protobuf": "^3.4", + "grpc/grpc": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "4.8.*", + "squizlabs/php_codesniffer": "2.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\GAX\\": "src/", + "Google\\GAX\\UnitTests\\": "tests/", + "Google\\": "src/generated/Google/", + "GPBMetadata\\": "src/generated/GPBMetadata/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Google API Extensions for PHP", + "homepage": "https://github.com/googleapis/gax-php", + "keywords": [ + "google" + ], + "time": "2017-08-31T21:40:57+00:00" + }, + { + "name": "google/proto-client", + "version": "0.23.0", + "source": { + "type": "git", + "url": "https://github.com/googleapis/proto-client-php.git", + "reference": "b159f408b6acdba55bf727c3639d03bb0117fc27" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/proto-client-php/zipball/b159f408b6acdba55bf727c3639d03bb0117fc27", + "reference": "b159f408b6acdba55bf727c3639d03bb0117fc27", + "shasum": "" + }, + "require": { + "google/protobuf": "^3.3.2", + "php": ">=5.5" + }, + "require-dev": { + "google/gax": ">=0.20.0", + "phpunit/phpunit": "4.8.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\": "src/Google/", + "GPBMetadata\\": "src/GPBMetadata/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "Generated proto and gRPC classes for Google Cloud Platform in PHP", + "homepage": "https://github.com/googleapis/proto-client-php", + "keywords": [ + "google" + ], + "time": "2017-09-01T22:33:04+00:00" + }, + { + "name": "google/protobuf", + "version": "v3.5.2", + "source": { + "type": "git", + "url": "https://github.com/google/protobuf.git", + "reference": "b5fbb742af122b565925987e65c08957739976a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/google/protobuf/zipball/b5fbb742af122b565925987e65c08957739976a7", + "reference": "b5fbb742af122b565925987e65c08957739976a7", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4.8.0" + }, + "suggest": { + "ext-bcmath": "Need to support JSON deserialization" + }, + "type": "library", + "autoload": { + "psr-4": { + "Google\\Protobuf\\": "php/src/Google/Protobuf", + "GPBMetadata\\Google\\Protobuf\\": "php/src/GPBMetadata/Google/Protobuf" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "proto library for PHP", + "homepage": "https://developers.google.com/protocol-buffers/", + "keywords": [ + "proto" + ], + "time": "2018-03-06T03:54:18+00:00" + }, + { + "name": "grpc/grpc", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/grpc/grpc-php.git", + "reference": "741f59bac86c7b5e45818c8f2eec6980921bce23" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/grpc/grpc-php/zipball/741f59bac86c7b5e45818c8f2eec6980921bce23", + "reference": "741f59bac86c7b5e45818c8f2eec6980921bce23", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "google/auth": "v0.9" + }, + "suggest": { + "ext-protobuf": "For better performance, install the protobuf C extension.", + "google/protobuf": "To get started using grpc quickly, install the native protobuf library." + }, + "type": "library", + "autoload": { + "psr-4": { + "Grpc\\": "src/lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "gRPC library for PHP", + "homepage": "https://grpc.io", + "keywords": [ + "rpc" + ], + "time": "2018-03-28T22:54:08+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "6.3.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "68d0ea14d5a3f42a20e87632a5f84931e2709c90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/68d0ea14d5a3f42a20e87632a5f84931e2709c90", + "reference": "68d0ea14d5a3f42a20e87632a5f84931e2709c90", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.3-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2018-03-26T16:33:04+00:00" + }, + { + "name": "guzzlehttp/promises", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2016-12-20T10:07:11+00:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2017-03-20T17:10:46+00:00" + }, + { + "name": "monolog/monolog", + "version": "1.23.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/fd8c787753b3a2ad11bc60c063cff1358a32a3b4", + "reference": "fd8c787753b3a2ad11bc60c063cff1358a32a3b4", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "~1.0" + }, + "provide": { + "psr/log-implementation": "1.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "graylog2/gelf-php": "~1.0", + "jakub-onderka/php-parallel-lint": "0.9", + "php-amqplib/php-amqplib": "~2.4", + "php-console/php-console": "^3.1.3", + "phpunit/phpunit": "~4.5", + "phpunit/phpunit-mock-objects": "2.3.0", + "ruflin/elastica": ">=0.90 <3.0", + "sentry/sentry": "^0.13", + "swiftmailer/swiftmailer": "^5.3|^6.0" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mongo": "Allow sending log messages to a MongoDB server", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "php-console/php-console": "Allow sending log messages to Google Chrome", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server", + "sentry/sentry": "Allow sending log messages to a Sentry server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "http://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "time": "2017-06-19T01:22:40+00:00" + }, + { + "name": "psr/cache", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "time": "2016-08-06T20:24:11+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, + { + "name": "psr/log", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2016-10-10T12:19:37+00:00" + }, + { + "name": "rize/uri-template", + "version": "0.3.2", + "source": { + "type": "git", + "url": "https://github.com/rize/UriTemplate.git", + "reference": "9e5fdd5c47147aa5adf7f760002ee591ed37b9ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rize/UriTemplate/zipball/9e5fdd5c47147aa5adf7f760002ee591ed37b9ca", + "reference": "9e5fdd5c47147aa5adf7f760002ee591ed37b9ca", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Rize\\UriTemplate": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marut K", + "homepage": "http://twitter.com/rezigned" + } + ], + "description": "PHP URI Template (RFC 6570) supports both expansion & extraction", + "keywords": [ + "RFC 6570", + "template", + "uri" + ], + "time": "2017-06-14T03:57:53+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_no_google_cloud/composer.json b/php-base/tests/samples/stackdriver_no_google_cloud/composer.json similarity index 100% rename from builder/gen-dockerfile/tests/test_data/stackdriver_no_google_cloud/composer.json rename to php-base/tests/samples/stackdriver_no_google_cloud/composer.json diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_old_er/composer.json b/php-base/tests/samples/stackdriver_old_er/composer.json similarity index 64% rename from builder/gen-dockerfile/tests/test_data/stackdriver_old_er/composer.json rename to php-base/tests/samples/stackdriver_old_er/composer.json index 7ffa29b7..9785b370 100644 --- a/builder/gen-dockerfile/tests/test_data/stackdriver_old_er/composer.json +++ b/php-base/tests/samples/stackdriver_old_er/composer.json @@ -1,6 +1,6 @@ { "require": { - "google/cloud-logging": "^1.4.1", + "google/cloud-logging": "*", "google/cloud-error-reporting": "^0.3.0" } } diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_old_google_cloud/composer.json b/php-base/tests/samples/stackdriver_old_google_cloud/composer.json similarity index 100% rename from builder/gen-dockerfile/tests/test_data/stackdriver_old_google_cloud/composer.json rename to php-base/tests/samples/stackdriver_old_google_cloud/composer.json diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_old_logging/composer.json b/php-base/tests/samples/stackdriver_old_logging/composer.json similarity index 100% rename from builder/gen-dockerfile/tests/test_data/stackdriver_old_logging/composer.json rename to php-base/tests/samples/stackdriver_old_logging/composer.json diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_simple/composer.json b/php-base/tests/samples/stackdriver_simple/composer.json similarity index 100% rename from builder/gen-dockerfile/tests/test_data/stackdriver_simple/composer.json rename to php-base/tests/samples/stackdriver_simple/composer.json diff --git a/builder/gen-dockerfile/tests/test_data/stackdriver_wildcard/composer.json b/php-base/tests/samples/stackdriver_wildcard/composer.json similarity index 100% rename from builder/gen-dockerfile/tests/test_data/stackdriver_wildcard/composer.json rename to php-base/tests/samples/stackdriver_wildcard/composer.json