Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0d5dd2
commit 5db3711
Showing
56 changed files
with
1,431 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Drupal editor configuration normalization | ||
# @see http://editorconfig.org/ | ||
|
||
# This is the top-most .editorconfig file; do not search in parent directories. | ||
root = true | ||
|
||
# All files. | ||
[*] | ||
end_of_line = LF | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[composer.{json,lock}] | ||
indent_size = 4 | ||
|
||
[.platform.app.yaml] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
vendor | ||
files | ||
data | ||
private | ||
.platform/local | ||
|
||
*.sql | ||
*.tar.gz | ||
*.tar | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: lando-platformsh-mariadb-10.0 | ||
recipe: platformsh | ||
config: | ||
id: DISCONNECTED | ||
excludes: | ||
- vendor | ||
- files | ||
- private | ||
|
||
# This is important because it lets lando know to test against the plugin in this repo | ||
# DO NOT REMOVE THIS! | ||
plugins: | ||
"@lando/platformsh": ./../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: app | ||
type: "php:7.3" | ||
disk: 1024 | ||
build: | ||
flavor: composer | ||
web: | ||
locations: | ||
"/": | ||
root: "." | ||
passthru: "/index.php" | ||
relationships: | ||
mariadb: 'mariadb:mysql' | ||
mounts: | ||
'files': | ||
source: local | ||
source_path: files | ||
'private': | ||
source: local | ||
source_path: private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# The routes of the project. | ||
# | ||
# Each route describes how an incoming URL is going | ||
# to be processed by Platform.sh. | ||
|
||
"https://{default}/": | ||
type: upstream | ||
upstream: "app:http" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mariadb: | ||
type: mariadb:10.0 | ||
disk: 512 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Platform.sh MariaDB 10.0 Example | ||
================================ | ||
|
||
This example exists to test this plugin's implementation of Platform.sh's `mariadb:10.0` service. | ||
|
||
* [Platform.sh MariaDB 10.0](https://docs.platform.sh/configuration/services/mysql.html) | ||
|
||
Start up tests | ||
-------------- | ||
|
||
Run the following commands to get up and running with this example. | ||
|
||
```bash | ||
# Should poweroff | ||
lando poweroff | ||
|
||
# Should start up successfully | ||
lando start | ||
``` | ||
|
||
Verification commands | ||
--------------------- | ||
|
||
Run the following commands to validate things are rolling as they should. | ||
|
||
```bash | ||
# Should have the expected platformsh containers and images | ||
docker ps --filter label=com.docker.compose.project=landoplatformshmariadb100 | grep docker.registry.platform.sh/php-7.3 | grep landoplatformshmariadb100_app_1 | ||
docker ps --filter label=com.docker.compose.project=landoplatformshmariadb100 | grep docker.registry.platform.sh/mariadb-10.0 | grep landoplatformshmariadb100_mariadb_1 | ||
|
||
# Should be running all application containers as web | ||
lando ssh -s app -c "id" | grep web | ||
|
||
# Should have the platform cli in all application containers | ||
lando ssh -s app -c "platform -V" | ||
|
||
# Should be running the correct php version | ||
lando ssh -s app -c "php --version" | grep 7.3. | ||
|
||
# Should be running all mariadb containers as app | ||
lando ssh -s mariadb -c "id" | grep app | ||
|
||
# Should be running the correct mariadb versions | ||
lando ssh -s mariadb -c "mysql -V" | grep 10.0. | ||
|
||
# Should be able to connect to all mariadb relationships | ||
lando mariadb main -e "show tables;" | ||
|
||
# Should be able to connect to mysql from the application containers | ||
lando ssh -s app -c "curl -I localhost/mysql.php" | grep HTTP/1.1 | grep "200 OK" | ||
``` | ||
|
||
Destroy tests | ||
------------- | ||
|
||
Run the following commands to trash this app like nothing ever happened. | ||
|
||
```bash | ||
# Should be able to destroy our app | ||
lando destroy -y | ||
|
||
# Should poweroff | ||
lando poweroff | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "lando/platformsh-mysql", | ||
"description": "A basic application to test Lando's implementation of platformsh's mysql service.", | ||
"license": "MIT", | ||
"type" : "project", | ||
"require": { | ||
"php": ">7.2", | ||
"platformsh/config-reader": "~2.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"App\\": "src/" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
HELLO! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
use Platformsh\ConfigReader\Config; | ||
|
||
// Create a new config object to ease reading the Platform.sh environment variables. | ||
// You can alternatively use getenv() yourself. | ||
$config = new Config(); | ||
|
||
// The 'database' relationship is generally the name of primary SQL database of an application. | ||
// That's not required, but much of our default automation code assumes it. | ||
$credentials = $config->credentials('mariadb'); | ||
|
||
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 | ||
<table> | ||
<thead> | ||
<tr><th>Name</th><th>City</th></tr> | ||
</thead> | ||
<tbody> | ||
TABLE; | ||
foreach ($result as $record) { | ||
printf("<tr><td>%s</td><td>%s</td></tr>\n", $record->name, $record->city); | ||
} | ||
print "</tbody>\n</table>\n"; | ||
} | ||
|
||
// Drop table | ||
$sql = "DROP TABLE People"; | ||
$conn->query($sql); | ||
|
||
} catch (\Exception $e) { | ||
http_response_code(500); | ||
print $e->getMessage(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Drupal editor configuration normalization | ||
# @see http://editorconfig.org/ | ||
|
||
# This is the top-most .editorconfig file; do not search in parent directories. | ||
root = true | ||
|
||
# All files. | ||
[*] | ||
end_of_line = LF | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[composer.{json,lock}] | ||
indent_size = 4 | ||
|
||
[.platform.app.yaml] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
vendor | ||
files | ||
data | ||
private | ||
.platform/local | ||
|
||
*.sql | ||
*.tar.gz | ||
*.tar | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: lando-platformsh-mariadb-10.1 | ||
recipe: platformsh | ||
config: | ||
id: DISCONNECTED | ||
|
||
|
||
# This is important because it lets lando know to test against the plugin in this repo | ||
# DO NOT REMOVE THIS! | ||
plugins: | ||
"@lando/platformsh": ./../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: app | ||
type: "php:7.3" | ||
disk: 1024 | ||
build: | ||
flavor: composer | ||
web: | ||
locations: | ||
"/": | ||
root: "." | ||
passthru: "/index.php" | ||
relationships: | ||
mariadb: 'mariadb:mysql' | ||
mounts: | ||
'files': | ||
source: local | ||
source_path: files | ||
'private': | ||
source: local | ||
source_path: private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# The routes of the project. | ||
# | ||
# Each route describes how an incoming URL is going | ||
# to be processed by Platform.sh. | ||
|
||
"https://{default}/": | ||
type: upstream | ||
upstream: "app:http" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mariadb: | ||
type: mariadb:10.1 | ||
disk: 512 |
Oops, something went wrong.