Interactive Serverless Playground

 

30.05.2020

@xf3l1x
f3l1x.io

Why

Why?

  1. Idea
  2. Challenge
  3. Experience
  4. Utils & tools
  5. Fun

accepted!

(latte examples)

Research

jsfiddle.net

codesandbox.io

Github Codespaces

regex101.com

3v4l.org

php.wtf

phpstan.org

getrector.org

tinkerwell.app

PHP sandboxes

  1. 3v4l.org (php.wtf)

  2. phpstan.org

  3. getrector.org

  4. tinkerwell.app

  5. w3schools.com

  6. phpfiddle.org

  7. onlinephpfunctions.com

  8. writephponline.com

  9. phptester.net

  10. paiza.io

ARE YOU F*'N KIDDING ME?

Features

Features

  • HTTP-based
  • microservices
  • first-class-nette
  • user-friendly
  • easy-to-maintain
  • persistent
  • zero-costs

How

VPS

  1. Charged 24/7 

  2. Maintenance

  3. Security updates

  4. Scaling up/down

WebAssembly

emconfigure ./configure \
  --disable-all \
  --disable-cgi \
  --disable-cli \
  --disable-rpath \
  --disable-phpdbg \
  --with-valgrind=no \
  --without-pear \
  --without-pcre-jit \
  --with-layout=GNU \
  --enable-embed=static \
  --enable-bcmath \
  --enable-json \
  --enable-ctype \
  --enable-mbstring \
  --disable-mbregex \
  --enable-tokenizer
emcc -O3 \
  --llvm-lto 2 \
  -s ENVIRONMENT=web \
  -s EXPORTED_FUNCTIONS='["_pib_eval", "_php_embed_init", "_zend_eval_string", "_php_embed_shutdown"]' \
  -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall"]' \
  -s MODULARIZE=1 \
  -s EXPORT_NAME="'PHP'" \
  -s TOTAL_MEMORY=134217728 \
  -s ASSERTIONS=0 \
  -s INVOKE_RUN=0 \
  -s ERROR_ON_UNDEFINED_SYMBOLS=0 \
  --preload-file Zend/bench.php \
  libs/libphp7.a pib_eval.o -o out/php.js

Serverless

{
  "functions": {
  }
}

Vercel + PHP

now.json

{
  "functions": {
    "api/index.php": {
      "runtime": "now-php@0.0.9"
    }
  }
}

Vercel + PHP

now.json

👨🏻‍💻

Dreamed Architecture

WEB

Text

STORAGE

NETTE

STRINGS

a

TIME

XYZ

ANALYTICS

SERVICES

Textarea Architecture

UI

DB
(mysql)

save

UI

load

<TEXTAREA>

<CODE>

Name!

lessik

serverless

lesík

lessik
├── services
│   ├── nette (PHP)
│   │   ├── api/*.php
│   │   ├── src
│   │   ├── now.json
│   │   └── composer.json
│   ├── strings (PHP)
│   │   ├── api/*.php
│   │   ├── src
│   │   ├── now.json
│   │   └── composer.json
│   ├── time (PHP)
│   │   ├── api/*.php
│   │   ├── src
│   │   ├── now.json
│   │   └── composer.json
├── sites (JS, TS, Vue)
│   └── lessik
│       ├── src
│       ├── now.json
│       ├── tsconfig.json
│       ├── tailwind.config.js
│       └── package.json
└── Makefile
make sites-lessik-dev
make services-nette-dev
make services-strings-dev

0.0.0.0:1234

Parcel JS

PHP built-in server

0.0.0.0:8000

PHP built-in server

0.0.0.0:8001

Development

terminals

Development

app.ts

export const NAME = "LESSIK";
export const VERSION = "v0.1";

// Services

export const SERVICE_NETTE = 
	process.env.SERVICE_NETTE || 'http://0.0.0.0:8000';

export const SERVICE_STRINGS = 
	process.env.SERVICE_STRINGS || 'http://0.0.0.0:8001';

Development

request & response

const output = await fetch(SERVICE_NETTE, {body});
<?php declare(strict_types = 1);

$latte = Request::param('code');
$output = ['result' => Runner::doLatte($latte)];

Response::header('content-type', 'application/json');
Response::code(200);
echo Json::encode($output);
exit();

Web UI (0.0.0.0:1234)

Nette Service (0.0.0.0:8000)

DEPLOYMENT

VERCEL

strings-v1.felix.tld

nette-v1.felix.tld

3rd party

  • monitoring

  • telemetry logs

  • error handling

  • analytics

  • custom

Dark Lang

web

Hold Your 🏇🏇🏇

Hold Your 🏇🏇🏇

Subscribe For Invitation

Conclusion

  • think big

  • take challenges

  • explore & conquer

  • share experience

  • have fun

🤩 😢

Time to selfie 📷

Github Sponsors

Thank you

Support My OSS

@xf3l1x
f3l1x.io

?

What? Why? How? No? Oh.

Thank you!

Go LESSIK!

@xf3l1x
f3l1x.io

2020-05-30 - Interactive Serverless Playground

By Milan Felix Å ulc

2020-05-30 - Interactive Serverless Playground

  • 55
Loading comments...

More from Milan Felix Å ulc