From b64946562381030f6c6989851a18b6b6c8355cfb Mon Sep 17 00:00:00 2001 From: chadcarlson Date: Thu, 18 Nov 2021 11:48:14 -0500 Subject: [PATCH 1/5] PHP only. --- golang/{.platform.app.yaml => ignore.platform.app.yaml} | 0 java/{.platform.app.yaml => ignore.platform.app.yaml} | 0 nodejs/{.platform.app.yaml => ignore.platform.app.yaml} | 0 python/{.platform.app.yaml => ignore.platform.app.yaml} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename golang/{.platform.app.yaml => ignore.platform.app.yaml} (100%) rename java/{.platform.app.yaml => ignore.platform.app.yaml} (100%) rename nodejs/{.platform.app.yaml => ignore.platform.app.yaml} (100%) rename python/{.platform.app.yaml => ignore.platform.app.yaml} (100%) diff --git a/golang/.platform.app.yaml b/golang/ignore.platform.app.yaml similarity index 100% rename from golang/.platform.app.yaml rename to golang/ignore.platform.app.yaml diff --git a/java/.platform.app.yaml b/java/ignore.platform.app.yaml similarity index 100% rename from java/.platform.app.yaml rename to java/ignore.platform.app.yaml diff --git a/nodejs/.platform.app.yaml b/nodejs/ignore.platform.app.yaml similarity index 100% rename from nodejs/.platform.app.yaml rename to nodejs/ignore.platform.app.yaml diff --git a/python/.platform.app.yaml b/python/ignore.platform.app.yaml similarity index 100% rename from python/.platform.app.yaml rename to python/ignore.platform.app.yaml From fafac889f5625f5d13e31814567fde8f79ad9877 Mon Sep 17 00:00:00 2001 From: chadcarlson Date: Thu, 18 Nov 2021 11:51:42 -0500 Subject: [PATCH 2/5] Remove routes. --- .platform/routes.yaml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.platform/routes.yaml b/.platform/routes.yaml index 67dda362..43d69b90 100644 --- a/.platform/routes.yaml +++ b/.platform/routes.yaml @@ -17,22 +17,22 @@ type: upstream upstream: "php:http" -"https://{default}/nodejs": - id: nodejs - type: upstream - upstream: "nodejs:http" +# "https://{default}/nodejs": +# id: nodejs +# type: upstream +# upstream: "nodejs:http" -"https://{default}/python": - id: python - type: upstream - upstream: "python:http" +# "https://{default}/python": +# id: python +# type: upstream +# upstream: "python:http" -"https://{default}/java": - id: java - type: upstream - upstream: "java:http" +# "https://{default}/java": +# id: java +# type: upstream +# upstream: "java:http" -"https://{default}/golang": - id: golang - type: upstream - upstream: "golang:http" +# "https://{default}/golang": +# id: golang +# type: upstream +# upstream: "golang:http" From 13aa88e994e5c7373cb4cf042dc5efa0f901fea0 Mon Sep 17 00:00:00 2001 From: chadcarlson Date: Thu, 18 Nov 2021 12:15:38 -0500 Subject: [PATCH 3/5] All ES versions to test. --- .platform/services.yaml | 142 +++++++++++------- main/web/index.html | 10 +- php/.platform.app.yaml | 15 +- ...{Elasticsearch.php => Elasticsearch65.php} | 2 +- php/examples/Elasticsearch68.php | 96 ++++++++++++ php/examples/Elasticsearch710.php | 96 ++++++++++++ php/examples/Elasticsearch72.php | 96 ++++++++++++ php/examples/Elasticsearch75.php | 96 ++++++++++++ php/examples/Elasticsearch77.php | 96 ++++++++++++ php/examples/Elasticsearch79.php | 96 ++++++++++++ php/examples/InfluxDB.php | 80 ---------- php/examples/Memcached.php | 33 ---- php/examples/MongoDB.php | 48 ------ php/examples/MySQL.php | 70 --------- php/examples/PostgreSQL.php | 66 -------- php/examples/RabbitMQ.php | 46 ------ php/examples/Redis.php | 32 ---- php/examples/Solr.php | 56 ------- 18 files changed, 672 insertions(+), 504 deletions(-) rename php/examples/{Elasticsearch.php => Elasticsearch65.php} (97%) create mode 100644 php/examples/Elasticsearch68.php create mode 100644 php/examples/Elasticsearch710.php create mode 100644 php/examples/Elasticsearch72.php create mode 100644 php/examples/Elasticsearch75.php create mode 100644 php/examples/Elasticsearch77.php create mode 100644 php/examples/Elasticsearch79.php delete mode 100644 php/examples/InfluxDB.php delete mode 100644 php/examples/Memcached.php delete mode 100644 php/examples/MongoDB.php delete mode 100644 php/examples/MySQL.php delete mode 100644 php/examples/PostgreSQL.php delete mode 100644 php/examples/RabbitMQ.php delete mode 100644 php/examples/Redis.php delete mode 100644 php/examples/Solr.php diff --git a/.platform/services.yaml b/.platform/services.yaml index 01a16d7e..89fd6966 100644 --- a/.platform/services.yaml +++ b/.platform/services.yaml @@ -1,74 +1,100 @@ # This file defines services you want available to your application. -elasticsearch77: - type: elasticsearch:7.7 +elasticsearch65: + type: elasticsearch:6.5 disk: 256 size: S -headlesschrome: - type: chrome-headless:73 - size: S -influxdb18: - type: influxdb:1.8 +elasticsearch68: + type: elasticsearch:6.8 disk: 256 size: S -kafka25: - type: kafka:2.5 - disk: 512 - size: S -mariadb104: - type: mariadb:10.4 +elasticsearch72: + type: elasticsearch:7.2 disk: 256 size: S -memcached16: - type: memcached:1.6 - size: S -mongodb36: - type: mongodb:3.6 - disk: 1024 - size: S -networkstorage: - type: network-storage:1.0 +elasticsearch75: + type: elasticsearch:7.5 disk: 256 size: S -oraclemysql: - type: oracle-mysql:8.0 +elasticsearch77: + type: elasticsearch:7.7 disk: 256 size: S -postgresql12: - type: postgresql:12 +elasticsearch79: + type: elasticsearch:7.9 disk: 256 size: S -rabbitmq38: - type: rabbitmq:3.8 - disk: 1024 - size: S -redis6: - type: redis:6.0 - size: S -solr86: - type: solr:8.6 +elasticsearch710: + type: elasticsearch:7.10 disk: 256 size: S - configuration: - cores: - maincore: - conf_dir: !archive "solr-config" - endpoints: - solr: - core: maincore -vault: - type: vault-kms:1.6 - disk: 512 - size: S - configuration: - endpoints: - sign: - - policy: admin - key: vault-sign - type: sign - - policy: sign - key: vault-sign - type: sign - - policy: verify - key: vault-sign - type: sign + + +# headlesschrome: +# type: chrome-headless:73 +# size: S +# influxdb18: +# type: influxdb:1.8 +# disk: 256 +# size: S +# kafka25: +# type: kafka:2.5 +# disk: 512 +# size: S +# mariadb104: +# type: mariadb:10.4 +# disk: 256 +# size: S +# memcached16: +# type: memcached:1.6 +# size: S +# mongodb36: +# type: mongodb:3.6 +# disk: 1024 +# size: S +# networkstorage: +# type: network-storage:1.0 +# disk: 256 +# size: S +# oraclemysql: +# type: oracle-mysql:8.0 +# disk: 256 +# size: S +# postgresql12: +# type: postgresql:12 +# disk: 256 +# size: S +# rabbitmq38: +# type: rabbitmq:3.8 +# disk: 1024 +# size: S +# redis6: +# type: redis:6.0 +# size: S +# solr86: +# type: solr:8.6 +# disk: 256 +# size: S +# configuration: +# cores: +# maincore: +# conf_dir: !archive "solr-config" +# endpoints: +# solr: +# core: maincore +# vault: +# type: vault-kms:1.6 +# disk: 512 +# size: S +# configuration: +# endpoints: +# sign: +# - policy: admin +# key: vault-sign +# type: sign +# - policy: sign +# key: vault-sign +# type: sign +# - policy: verify +# key: vault-sign +# type: sign diff --git a/main/web/index.html b/main/web/index.html index a01fe50a..8495a0bf 100644 --- a/main/web/index.html +++ b/main/web/index.html @@ -8,7 +8,7 @@

Platform.sh examples

What relationships look like

Languages

diff --git a/php/.platform.app.yaml b/php/.platform.app.yaml index 2939cad4..392b3bdc 100644 --- a/php/.platform.app.yaml +++ b/php/.platform.app.yaml @@ -30,15 +30,12 @@ hooks: # to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand # side is in the form `:`. relationships: - database: 'mariadb104:mysql' - postgresql: 'postgresql12:postgresql' - solr: 'solr86:solr' - redis: 'redis6:redis' - elasticsearch: 'elasticsearch77:elasticsearch' - mongodb: 'mongodb36:mongodb' - rabbitmq: 'rabbitmq38:rabbitmq' - influxdb: 'influxdb18:influxdb' - memcached: 'memcached16:memcached' + elasticsearch65: 'elasticsearch65:elasticsearch' + elasticsearch68: 'elasticsearch68:elasticsearch' + elasticsearch72: 'elasticsearch72:elasticsearch' + elasticsearch75: 'elasticsearch75:elasticsearch' + elasticsearch79: 'elasticsearch79:elasticsearch' + elasticsearch710: 'elasticsearch710:elasticsearch' # The size of the persistent disk of the application (in MB). disk: 128 diff --git a/php/examples/Elasticsearch.php b/php/examples/Elasticsearch65.php similarity index 97% rename from php/examples/Elasticsearch.php rename to php/examples/Elasticsearch65.php index f943b5f3..47702f61 100644 --- a/php/examples/Elasticsearch.php +++ b/php/examples/Elasticsearch65.php @@ -10,7 +10,7 @@ $config = new Config(); // Get the credentials to connect to the Elasticsearch service. -$credentials = $config->credentials('elasticsearch'); +$credentials = $config->credentials('elasticsearch65'); try { // The Elasticsearch library lets you connect to multiple hosts. diff --git a/php/examples/Elasticsearch68.php b/php/examples/Elasticsearch68.php new file mode 100644 index 00000000..77b71b43 --- /dev/null +++ b/php/examples/Elasticsearch68.php @@ -0,0 +1,96 @@ +credentials('elasticsearch68'); + +try { + // The Elasticsearch library lets you connect to multiple hosts. + // On Platform.sh Standard there is only a single host so just + // register that. + $hosts = [ + [ + 'scheme' => $credentials['scheme'], + 'host' => $credentials['host'], + 'port' => $credentials['port'], + ] + ]; + + // Create an Elasticsearch client object. + $builder = ClientBuilder::create(); + $builder->setHosts($hosts); + $client = $builder->build(); + + $index = 'my_index'; + $type = 'People'; + + // Index a few document. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $names = ['Ada Lovelace', 'Alonzo Church', 'Barbara Liskov']; + + foreach ($names as $name) { + $params['body']['name'] = $name; + $client->index($params); + } + + // Force just-added items to be indexed. + $client->indices()->refresh(array('index' => $index)); + + + // Search for documents. + $result = $client->search([ + 'index' => $index, + 'type' => $type, + 'body' => [ + 'query' => [ + 'match' => [ + 'name' => 'Barbara Liskov', + ], + ], + ], + ]); + + if (isset($result['hits']['hits'])) { + print << + + + + +TABLE; + foreach ($result['hits']['hits'] as $record) { + printf("\n", $record['_id'], $record['_source']['name']); + } + print "\n
IDName
%s%s
\n"; + } + + // Delete documents. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $ids = array_map(function($row) { + return $row['_id']; + }, $result['hits']['hits']); + + foreach ($ids as $id) { + $params['id'] = $id; + $client->delete($params); + } + +} catch (Exception $e) { + print $e->getMessage(); +} diff --git a/php/examples/Elasticsearch710.php b/php/examples/Elasticsearch710.php new file mode 100644 index 00000000..e7f5c4e0 --- /dev/null +++ b/php/examples/Elasticsearch710.php @@ -0,0 +1,96 @@ +credentials('elasticsearch710'); + +try { + // The Elasticsearch library lets you connect to multiple hosts. + // On Platform.sh Standard there is only a single host so just + // register that. + $hosts = [ + [ + 'scheme' => $credentials['scheme'], + 'host' => $credentials['host'], + 'port' => $credentials['port'], + ] + ]; + + // Create an Elasticsearch client object. + $builder = ClientBuilder::create(); + $builder->setHosts($hosts); + $client = $builder->build(); + + $index = 'my_index'; + $type = 'People'; + + // Index a few document. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $names = ['Ada Lovelace', 'Alonzo Church', 'Barbara Liskov']; + + foreach ($names as $name) { + $params['body']['name'] = $name; + $client->index($params); + } + + // Force just-added items to be indexed. + $client->indices()->refresh(array('index' => $index)); + + + // Search for documents. + $result = $client->search([ + 'index' => $index, + 'type' => $type, + 'body' => [ + 'query' => [ + 'match' => [ + 'name' => 'Barbara Liskov', + ], + ], + ], + ]); + + if (isset($result['hits']['hits'])) { + print << + + + + +TABLE; + foreach ($result['hits']['hits'] as $record) { + printf("\n", $record['_id'], $record['_source']['name']); + } + print "\n
IDName
%s%s
\n"; + } + + // Delete documents. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $ids = array_map(function($row) { + return $row['_id']; + }, $result['hits']['hits']); + + foreach ($ids as $id) { + $params['id'] = $id; + $client->delete($params); + } + +} catch (Exception $e) { + print $e->getMessage(); +} diff --git a/php/examples/Elasticsearch72.php b/php/examples/Elasticsearch72.php new file mode 100644 index 00000000..47a6fc8d --- /dev/null +++ b/php/examples/Elasticsearch72.php @@ -0,0 +1,96 @@ +credentials('elasticsearch72'); + +try { + // The Elasticsearch library lets you connect to multiple hosts. + // On Platform.sh Standard there is only a single host so just + // register that. + $hosts = [ + [ + 'scheme' => $credentials['scheme'], + 'host' => $credentials['host'], + 'port' => $credentials['port'], + ] + ]; + + // Create an Elasticsearch client object. + $builder = ClientBuilder::create(); + $builder->setHosts($hosts); + $client = $builder->build(); + + $index = 'my_index'; + $type = 'People'; + + // Index a few document. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $names = ['Ada Lovelace', 'Alonzo Church', 'Barbara Liskov']; + + foreach ($names as $name) { + $params['body']['name'] = $name; + $client->index($params); + } + + // Force just-added items to be indexed. + $client->indices()->refresh(array('index' => $index)); + + + // Search for documents. + $result = $client->search([ + 'index' => $index, + 'type' => $type, + 'body' => [ + 'query' => [ + 'match' => [ + 'name' => 'Barbara Liskov', + ], + ], + ], + ]); + + if (isset($result['hits']['hits'])) { + print << + + + + +TABLE; + foreach ($result['hits']['hits'] as $record) { + printf("\n", $record['_id'], $record['_source']['name']); + } + print "\n
IDName
%s%s
\n"; + } + + // Delete documents. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $ids = array_map(function($row) { + return $row['_id']; + }, $result['hits']['hits']); + + foreach ($ids as $id) { + $params['id'] = $id; + $client->delete($params); + } + +} catch (Exception $e) { + print $e->getMessage(); +} diff --git a/php/examples/Elasticsearch75.php b/php/examples/Elasticsearch75.php new file mode 100644 index 00000000..593204d7 --- /dev/null +++ b/php/examples/Elasticsearch75.php @@ -0,0 +1,96 @@ +credentials('elasticsearch75'); + +try { + // The Elasticsearch library lets you connect to multiple hosts. + // On Platform.sh Standard there is only a single host so just + // register that. + $hosts = [ + [ + 'scheme' => $credentials['scheme'], + 'host' => $credentials['host'], + 'port' => $credentials['port'], + ] + ]; + + // Create an Elasticsearch client object. + $builder = ClientBuilder::create(); + $builder->setHosts($hosts); + $client = $builder->build(); + + $index = 'my_index'; + $type = 'People'; + + // Index a few document. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $names = ['Ada Lovelace', 'Alonzo Church', 'Barbara Liskov']; + + foreach ($names as $name) { + $params['body']['name'] = $name; + $client->index($params); + } + + // Force just-added items to be indexed. + $client->indices()->refresh(array('index' => $index)); + + + // Search for documents. + $result = $client->search([ + 'index' => $index, + 'type' => $type, + 'body' => [ + 'query' => [ + 'match' => [ + 'name' => 'Barbara Liskov', + ], + ], + ], + ]); + + if (isset($result['hits']['hits'])) { + print << + + + + +TABLE; + foreach ($result['hits']['hits'] as $record) { + printf("\n", $record['_id'], $record['_source']['name']); + } + print "\n
IDName
%s%s
\n"; + } + + // Delete documents. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $ids = array_map(function($row) { + return $row['_id']; + }, $result['hits']['hits']); + + foreach ($ids as $id) { + $params['id'] = $id; + $client->delete($params); + } + +} catch (Exception $e) { + print $e->getMessage(); +} diff --git a/php/examples/Elasticsearch77.php b/php/examples/Elasticsearch77.php new file mode 100644 index 00000000..f5c00abc --- /dev/null +++ b/php/examples/Elasticsearch77.php @@ -0,0 +1,96 @@ +credentials('elasticsearch77'); + +try { + // The Elasticsearch library lets you connect to multiple hosts. + // On Platform.sh Standard there is only a single host so just + // register that. + $hosts = [ + [ + 'scheme' => $credentials['scheme'], + 'host' => $credentials['host'], + 'port' => $credentials['port'], + ] + ]; + + // Create an Elasticsearch client object. + $builder = ClientBuilder::create(); + $builder->setHosts($hosts); + $client = $builder->build(); + + $index = 'my_index'; + $type = 'People'; + + // Index a few document. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $names = ['Ada Lovelace', 'Alonzo Church', 'Barbara Liskov']; + + foreach ($names as $name) { + $params['body']['name'] = $name; + $client->index($params); + } + + // Force just-added items to be indexed. + $client->indices()->refresh(array('index' => $index)); + + + // Search for documents. + $result = $client->search([ + 'index' => $index, + 'type' => $type, + 'body' => [ + 'query' => [ + 'match' => [ + 'name' => 'Barbara Liskov', + ], + ], + ], + ]); + + if (isset($result['hits']['hits'])) { + print << + + + + +TABLE; + foreach ($result['hits']['hits'] as $record) { + printf("\n", $record['_id'], $record['_source']['name']); + } + print "\n
IDName
%s%s
\n"; + } + + // Delete documents. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $ids = array_map(function($row) { + return $row['_id']; + }, $result['hits']['hits']); + + foreach ($ids as $id) { + $params['id'] = $id; + $client->delete($params); + } + +} catch (Exception $e) { + print $e->getMessage(); +} diff --git a/php/examples/Elasticsearch79.php b/php/examples/Elasticsearch79.php new file mode 100644 index 00000000..913bf685 --- /dev/null +++ b/php/examples/Elasticsearch79.php @@ -0,0 +1,96 @@ +credentials('elasticsearch79'); + +try { + // The Elasticsearch library lets you connect to multiple hosts. + // On Platform.sh Standard there is only a single host so just + // register that. + $hosts = [ + [ + 'scheme' => $credentials['scheme'], + 'host' => $credentials['host'], + 'port' => $credentials['port'], + ] + ]; + + // Create an Elasticsearch client object. + $builder = ClientBuilder::create(); + $builder->setHosts($hosts); + $client = $builder->build(); + + $index = 'my_index'; + $type = 'People'; + + // Index a few document. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $names = ['Ada Lovelace', 'Alonzo Church', 'Barbara Liskov']; + + foreach ($names as $name) { + $params['body']['name'] = $name; + $client->index($params); + } + + // Force just-added items to be indexed. + $client->indices()->refresh(array('index' => $index)); + + + // Search for documents. + $result = $client->search([ + 'index' => $index, + 'type' => $type, + 'body' => [ + 'query' => [ + 'match' => [ + 'name' => 'Barbara Liskov', + ], + ], + ], + ]); + + if (isset($result['hits']['hits'])) { + print << + + + + +TABLE; + foreach ($result['hits']['hits'] as $record) { + printf("\n", $record['_id'], $record['_source']['name']); + } + print "\n
IDName
%s%s
\n"; + } + + // Delete documents. + $params = [ + 'index' => $index, + 'type' => $type, + ]; + + $ids = array_map(function($row) { + return $row['_id']; + }, $result['hits']['hits']); + + foreach ($ids as $id) { + $params['id'] = $id; + $client->delete($params); + } + +} catch (Exception $e) { + print $e->getMessage(); +} diff --git a/php/examples/InfluxDB.php b/php/examples/InfluxDB.php deleted file mode 100644 index c452f77e..00000000 --- a/php/examples/InfluxDB.php +++ /dev/null @@ -1,80 +0,0 @@ -credentials('influxdb'); - -try { - // Connecting to the InfluxDB server. By default it has no user defined, so you will need to create it. - $client = new Client($credentials['host'], $credentials['port']); - - $password = base64_encode(random_bytes(12)); - $client->admin->createUser('deploy_user', $password, Client\Admin::PRIVILEGE_ALL); - - // Now reconnect with an authenticated connection so that we can access a database. - $client = new Client($credentials['host'], $credentials['port'], 'deploy_user', $password); - $database = $client->selectDB('deploys'); - - // No database is created by default, so it needs to be created by the user. - if (!$database->exists()) { - $database->create(new RetentionPolicy('test', '1d', 2, true)); - } - - // Write some data. - $points = [ - new Point( - 'deploy_time', // name of the measurement - 0.64, // the measurement value - ['host' => 'server01', 'region' => 'us-west'], // optional tags - ['cpucount' => 10], // optional additional fields - 1546556400 // Time precision has to be set to seconds! - ), - new Point( - 'deploy_time', // name of the measurement - 0.84, // the measurement value - ['host' => 'server01', 'region' => 'us-west'], // optional tags - ['cpucount' => 10], // optional additional fields - 1547161200 // Time precision has to be set to seconds! - ), - ]; - $result = $database->writePoints($points, Database::PRECISION_SECONDS); - - // Read the data back. - $result = $database->query('select * from deploy_time LIMIT 5'); - $points = $result->getPoints(); - - if ($points) { - print << - - - - -TABLE; - foreach ($points as $point) { - printf("\n", $point['time'], $point['value']); - } - print "\n
TimestampValue
%s%s
\n"; - } - - - // Drop the database. - $database->drop(); - - // And remove the user. - $client->admin->dropUser('deploy_user'); - -} catch (Exception $e) { - print $e->getMessage(); -} diff --git a/php/examples/Memcached.php b/php/examples/Memcached.php deleted file mode 100644 index 9f93c449..00000000 --- a/php/examples/Memcached.php +++ /dev/null @@ -1,33 +0,0 @@ -credentials('memcached'); - -try { - // Connecting to Memcached server. - $memcached = new Memcached(); - $memcached->addServer($credentials['host'], $credentials['port']); - $memcached->setOption(Memcached::OPT_BINARY_PROTOCOL, true); - - $key = "Deploy day"; - $value = "Friday"; - - // Set a value. - $memcached->set($key, $value); - - // Read it back. - $test = $memcached->get($key); - - printf('Found value %s for key %s.', $test, $key); - -} catch (Exception $e) { - print $e->getMessage(); -} diff --git a/php/examples/MongoDB.php b/php/examples/MongoDB.php deleted file mode 100644 index 701d552b..00000000 --- a/php/examples/MongoDB.php +++ /dev/null @@ -1,48 +0,0 @@ -credentials('mongodb'); - -try { - - $server = sprintf('%s://%s:%s@%s:%d/%s', - $credentials['scheme'], - $credentials['username'], - $credentials['password'], - $credentials['host'], - $credentials['port'], - $credentials['path'] - ); - - $client = new Client($server); - $collection = $client->main->starwars; - - $result = $collection->insertOne([ - 'name' => 'Rey', - 'occupation' => 'Jedi', - ]); - - $id = $result->getInsertedId(); - - $document = $collection->findOne([ - '_id' => $id, - ]); - - // Clean up after ourselves. - $collection->drop(); - - printf("Found %s (%s)
\n", $document->name, $document->occupation); - -} catch (\Exception $e) { - print $e->getMessage(); -} diff --git a/php/examples/MySQL.php b/php/examples/MySQL.php deleted file mode 100644 index c601604f..00000000 --- a/php/examples/MySQL.php +++ /dev/null @@ -1,70 +0,0 @@ -credentials('database'); - -try { - // Connect to the database using PDO. If using some other abstraction layer you would - // inject the values from $database into whatever your abstraction layer asks for. - $dsn = sprintf('mysql:host=%s;port=%d;dbname=%s', $credentials['host'], $credentials['port'], $credentials['path']); - $conn = new \PDO($dsn, $credentials['username'], $credentials['password'], [ - // Always use Exception error mode with PDO, as it's more reliable. - \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, - // So we don't have to mess around with cursors and unbuffered queries by default. - \PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => TRUE, - // Make sure MySQL returns all matched rows on update queries including - // rows that actually didn't have to be updated because the values didn't - // change. This matches common behavior among other database systems. - \PDO::MYSQL_ATTR_FOUND_ROWS => TRUE, - ]); - - // Creating a table. - $sql = "CREATE TABLE People ( - id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, - name VARCHAR(30) NOT NULL, - city VARCHAR(30) NOT NULL - )"; - $conn->query($sql); - - // Insert data. - $sql = "INSERT INTO People (name, city) VALUES - ('Neil Armstrong', 'Moon'), - ('Buzz Aldrin', 'Glen Ridge'), - ('Sally Ride', 'La Jolla');"; - $conn->query($sql); - - // Show table. - $sql = "SELECT * FROM People"; - $result = $conn->query($sql); - $result->setFetchMode(\PDO::FETCH_OBJ); - - if ($result) { - print << - - - - -TABLE; - foreach ($result as $record) { - printf("\n", $record->name, $record->city); - } - print "\n
NameCity
%s%s
\n"; - } - - // Drop table - $sql = "DROP TABLE People"; - $conn->query($sql); - -} catch (\Exception $e) { - print $e->getMessage(); -} diff --git a/php/examples/PostgreSQL.php b/php/examples/PostgreSQL.php deleted file mode 100644 index 73d8256c..00000000 --- a/php/examples/PostgreSQL.php +++ /dev/null @@ -1,66 +0,0 @@ -credentials('postgresql'); - -try { - // Connect to the database using PDO. If using some other abstraction layer you would - // inject the values from $database into whatever your abstraction layer asks for. - $dsn = sprintf('pgsql:host=%s;port=%d;dbname=%s', $credentials['host'], $credentials['port'], $credentials['path']); - $conn = new \PDO($dsn, $credentials['username'], $credentials['password'], [ - // Always use Exception error mode with PDO, as it's more reliable. - \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, - ]); - - $conn->query("DROP TABLE IF EXISTS People"); - - // Creating a table. - $sql = "CREATE TABLE IF NOT EXISTS People ( - id SERIAL PRIMARY KEY, - name VARCHAR(30) NOT NULL, - city VARCHAR(30) NOT NULL - )"; - $conn->query($sql); - - // Insert data. - $sql = "INSERT INTO People (name, city) VALUES - ('Neil Armstrong', 'Moon'), - ('Buzz Aldrin', 'Glen Ridge'), - ('Sally Ride', 'La Jolla');"; - $conn->query($sql); - - // Show table. - $sql = "SELECT * FROM People"; - $result = $conn->query($sql); - $result->setFetchMode(\PDO::FETCH_OBJ); - - if ($result) { - print << - - - - -TABLE; - foreach ($result as $record) { - printf("\n", $record->name, $record->city); - } - print "\n
NameCity
%s%s
\n"; - } - - // Drop table. - $sql = "DROP TABLE People"; - $conn->query($sql); - -} catch (\Exception $e) { - print $e->getMessage(); -} diff --git a/php/examples/RabbitMQ.php b/php/examples/RabbitMQ.php deleted file mode 100644 index e4b66b68..00000000 --- a/php/examples/RabbitMQ.php +++ /dev/null @@ -1,46 +0,0 @@ -credentials('rabbitmq'); - -try { - - $queueName = 'deploy_days'; - - // Connect to the RabbitMQ server. - $connection = new AMQPStreamConnection($credentials['host'], $credentials['port'], $credentials['username'], $credentials['password']); - $channel = $connection->channel(); - - $channel->queue_declare($queueName, false, false, false, false); - - $msg = new AMQPMessage('Friday'); - $channel->basic_publish($msg, '', 'hello'); - - echo "[x] Sent 'Friday'
\n"; - - // In a real application you't put the following in a separate script in a loop. - $callback = function ($msg) { - printf("[x] Deploying on %s
\n", $msg->body); - }; - - $channel->basic_consume($queueName, '', false, true, false, false, $callback); - - // This blocks on waiting for an item from the queue, so comment it out in this demo script. - //$channel->wait(); - - $channel->close(); - $connection->close(); - -} catch (Exception $e) { - print $e->getMessage(); -} diff --git a/php/examples/Redis.php b/php/examples/Redis.php deleted file mode 100644 index faf9b556..00000000 --- a/php/examples/Redis.php +++ /dev/null @@ -1,32 +0,0 @@ -credentials('redis'); - -try { - // Connecting to Redis server. - $redis = new Redis(); - $redis->connect($credentials['host'], $credentials['port']); - - $key = "Deploy day"; - $value = "Friday"; - - // Set a value. - $redis->set($key, $value); - - // Read it back. - $test = $redis->get($key); - - printf('Found value %s for key %s.', $test, $key); - -} catch (Exception $e) { - print $e->getMessage(); -} diff --git a/php/examples/Solr.php b/php/examples/Solr.php deleted file mode 100644 index 0c54b7ee..00000000 --- a/php/examples/Solr.php +++ /dev/null @@ -1,56 +0,0 @@ -credentials('solr'); - -try { - - $config = [ - 'endpoint' => [ - 'localhost' => [ - 'host' => $credentials['host'], - 'port' => $credentials['port'], - 'path' => "/" . $credentials['path'], - ] - ] - ]; - - $client = new Client($config); - - // Add a document - $update = $client->createUpdate(); - - $doc1 = $update->createDocument(); - $doc1->id = 123; - $doc1->name = 'Valentina Tereshkova'; - - $update->addDocuments(array($doc1)); - $update->addCommit(); - - $result = $client->update($update); - print "Adding one document. Status (0 is success): " .$result->getStatus(). "
\n"; - - // Select one document - $query = $client->createQuery($client::QUERY_SELECT); - $resultset = $client->execute($query); - print "Selecting documents (1 expected): " .$resultset->getNumFound() . "
\n"; - - // Delete one document - $update = $client->createUpdate(); - - $update->addDeleteById(123); - $update->addCommit(); - $result = $client->update($update); - print "Deleting one document. Status (0 is success): " .$result->getStatus(). "
\n"; - -} catch (Exception $e) { - print $e->getMessage(); -} From a7dfe2d3574aadcc10ee66bad51ff96efb7a61e8 Mon Sep 17 00:00:00 2001 From: chadcarlson Date: Thu, 18 Nov 2021 12:17:59 -0500 Subject: [PATCH 4/5] Update main. --- main/.platform.app.yaml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/main/.platform.app.yaml b/main/.platform.app.yaml index 507ee8fa..960f594c 100644 --- a/main/.platform.app.yaml +++ b/main/.platform.app.yaml @@ -14,19 +14,12 @@ hooks: curl -sS https://platform.sh/cli/installer | php relationships: - elasticsearch: 'elasticsearch77:elasticsearch' - headlesschrome: 'headlesschrome:http' - influxdb: 'influxdb18:influxdb' - kafka: 'kafka25:kafka' - memcached: 'memcached16:memcached' - mongodb: 'mongodb36:mongodb' - oraclemysql: 'oraclemysql:mysql' - mysql: 'mariadb104:mysql' - postgresql: 'postgresql12:postgresql' - rabbitmq: 'rabbitmq38:rabbitmq' - redis: 'redis6:redis' - solr: 'solr86:solr' - vault: 'vault:sign' + elasticsearch65: 'elasticsearch65:elasticsearch' + elasticsearch68: 'elasticsearch68:elasticsearch' + elasticsearch72: 'elasticsearch72:elasticsearch' + elasticsearch75: 'elasticsearch75:elasticsearch' + elasticsearch79: 'elasticsearch79:elasticsearch' + elasticsearch710: 'elasticsearch710:elasticsearch' # The size of the persistent disk of the application (in MB). disk: 128 From 65190274116b1be9b2a1f004396f5501b227097f Mon Sep 17 00:00:00 2001 From: chadcarlson Date: Thu, 18 Nov 2021 12:18:56 -0500 Subject: [PATCH 5/5] Remove ns mount. --- main/.platform.app.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main/.platform.app.yaml b/main/.platform.app.yaml index 960f594c..74c95f1b 100644 --- a/main/.platform.app.yaml +++ b/main/.platform.app.yaml @@ -45,8 +45,8 @@ crons: platform redeploy --yes --no-wait fi -mounts: - networkstorage: - source: service - service: networkstorage - source_path: networkstorage +# mounts: +# networkstorage: +# source: service +# service: networkstorage +# source_path: networkstorage