(Source: @bassamtabbara)
What is cloud
computing?
What is
The Cloud?
These are separate questions...
Someone else's hard drive
Abstracting away physical infrastructure
Disposable application design
Your application is disposable.
Your data is not.
You don't get an in-between option
Cleanly separate "Dev provided" and "user provided" files
Does config come from the developer or the user?
Git or Database?
Decide
getenv('foo');
$_ENV['foo'];
$_ENV['foo']['bar'];
Only ever use getenv()
Need glue code
// platform_parameters.php
if (getenv('PLATFORM_RELATIONSHIPS')) {
$relationships = json_decode(base64_decode(getenv('PLATFORM_RELATIONSHIPS')), true);
foreach ($relationships['database'] as $endpoint) {
if (!empty($endpoint['query']['is_master'])) {
$container->setParameter('database_driver', 'pdo_'.$endpoint['scheme']);
$container->setParameter('database_host', $endpoint['host']);
$container->setParameter('database_port', $endpoint['port']);
$container->setParameter('database_name', $endpoint['path']);
$container->setParameter('database_user', $endpoint['username']);
$container->setParameter('database_password', $endpoint['password']);
break;
}
}
}
$container->setParameter('kernel.secret', getenv('PLATFORM_PROJECT_ENTROPY'));
composer require platformsh/symfonyflex-bridge
function mapPlatformShEnvironment() : void
{
$config = new Config();
$secret = getenv('APP_SECRET') ?: $config->projectEntropy;
setEnvVar('APP_SECRET', $secret);
$appEnv = getenv('APP_ENV') ?: 'prod';
setEnvVar('APP_ENV', $appEnv);
mapPlatformShDatabase('database', $config);
if (!getenv('MAILER_DSN')) {
mapPlatformShMailer($config);
}
}
// ...
composer require platformsh/laravel-bridge
function mapPlatformShEnvironment() : void
{
$config = new Config();
$secret = "base64:" . base64_encode(substr(
base64_decode($config->projectEntropy), 0, 32));
setEnvVar('APP_KEY', $secret);
$secure_cookie = getenv('SESSION_SECURE_COOKIE') ?: 1;
setEnvVar('SESSION_SECURE_COOKIE', $secure_cookie);
mapAppUrl($config);
mapPlatformShDatabase('database', $config);
mapPlatformShRedisCache('rediscache', $config);
mapPlatformShRedisSession('redissession', $config);
}
// ...
const platformsh = require('platformsh-config');
let config = platformsh.config();
const credentials = config.credentials('database');
const connection = await mysql.createConnection({
host: credentials.host,
port: credentials.port,
user: credentials.username,
password: credentials.password,
database: credentials.path,
});
var app = express();
// ...
app.listen(config.port);
composer.json
{
"autoload": {
"files": ["extra-bridge.php"]
}
}
Only works if your app reads env vars...
Use DotEnv (.env
files)
(Many to pick from in every language)
(App-specific configuration)
Request::setTrustedHosts()
Constants? Static config files?
Dependency inject your environment
Cloud
Always be able to
take your business elsewhere.
Source: WordStream (2015)
Use Free Software
Use replaceable services
There is no industry consensus yet regarding the properties of microservices, and an official definition is missing as well.
(Sources: Wikipedia, Martin Fowler)
Every microservice treats every other microservice as a separate 3rd party
that may as well be a different company.
Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.
"If one of your microservices going down means the others don't work, you don't have a microservice; you have a distributed monolith."
—A few dozen people
So if microservices aren't for me, what is?
You've probably already done this
Cron jobs
Queue workers
"Admin" application
API app
All asynchronous
Remember what they say when you assume
Director of Developer Experience Platform.sh
The end-to-end web platform for agile teams
Stalk us at @PlatformSH