Skip to content

About

Devcontainer Setup for Marko PHP Framework

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

48 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Marko.build Devcontainer

A ready-to-use dev container for Marko.build projects. Opens in VS Code Dev Containers or GitHub Codespaces and scaffolds a new Marko project automatically.

What's included

  • PHP (latest) + Composer
  • Node.js (LTS) + Tailwind CSS
  • MySQL or PostgreSQL (via Docker Compose)
  • Redis (via Docker Compose)
  • Docker-in-Docker
  • Port 8000 forwarded for the dev server

Getting started

Github Codespaces:

  1. Fork the https://github.com/artmuscode/codespaces-marko

  2. Edit section below in .devcontainer/devcontainer.json and save changes

"containerEnv": { "MARKO_PROJECT_NAME": "palettes", "MARKO_INSTALL_MODE": "skeleton", "MARKO_PACKAGES": "marko/database marko/cache-redis marko/session marko/view marko/view-latte marko/security marko/testing marko/database-mysql" },

*note - If you plan to use a postgres DB replace "marko/database-mysql" with "marko/database-pgsql", plus change database container in compose.yml

  1. Edit .devcontainer/compose.yml and/or package.json to add required docker images/containers. Add NODE packages to package.json/ additional scripts etc. Save changes.

  2. Open Github hamburger menu Top Left -> select Codespaces

  3. Click Green Button Top Right "New codespace"

  4. Create a new codespace -> Select a repository: "username/codespaces-marko" -> Branch: main -> Region: Default (US East) -> Machine Type: Many options

  5. Click Green Button "Create codespace"

  6. New Window Open -> VS Code like editor -> Devcontainer will automatically start build process this will take a few minutes. -> terminal cmd: cd project-name -> terminal cmd: marko up

Deskop VS Code:

  1. Clone this repository locally

  2. Open the folder in VS Code

    Step 2

    Edit section below in .devcontainer/devcontainer.json and save changes

    Snippet area to change in devcontainer.json "containerEnv": { "MARKO_PROJECT_NAME": "palettes", "MARKO_INSTALL_MODE": "skeleton", "MARKO_PACKAGES": "marko/database marko/cache-redis marko/session marko/view marko/view-latte marko/security marko/testing marko/database-mysql" },

    Edit .devcontainer/compose.yml and/or package.json to add required docker images/containers. Add NODE packages to package.json/ additional scripts etc. Save changes.

    *note - If you plan to use a postgres DB replace "marko/database-mysql" with "marko/database-pgsql", plus change database container in compose.yml

  3. Click Show Commands

    Step 3

  4. Click Dev Containers: Rebuild and Reopen in Container

    Step 4

  5. VS Code will start devcontainer build, this will take a few minutes

  6. -> terminal cmd: cd project-name -> terminal cmd: marko up

  • Note running from Desktop VS Code requires Marko "host" configuration to be changed to "0.0.0.0". You will need to first run -> marko down -> add host 0.0.0.0 to marko project config -> then run marko up.

General Configuration

All project settings live in .devcontainer/devcontainer.json under containerEnv:

Variable Default Description
MARKO_PROJECT_NAME project-name Folder name for the scaffolded project
MARKO_INSTALL_MODE skeleton skeleton or framework
MARKO_PACKAGES see file Space-separated Composer packages to install

Change MARKO_PROJECT_NAME and rebuild — the project folder and shell PATH update automatically.

Marko CLI

The marko CLI is available globally after the build:

marko        # list available commands

Docker Compose services

A compose.yml is automatically copied into your project on first build. It defines the available backing services:

Service Image Default port
mysql mysql:8.4 3306
postgres postgres:16-alpine 5432
redis redis:7.2-alpine 6379

MySQL and Redis are enabled by default. PostgreSQL is commented out. To switch databases, open compose.yml in your project, comment out the mysql block, and uncomment postgres (and the postgres-data volume).

marko up will start whichever services are active.

Default database credentials:

Field Value
Host localhost
Database project name (e.g. palettes)
User marko
Password marko
Root password root

Node / Tailwind CSS

A package.json is automatically copied into your project on first build with Tailwind CSS v4 included as a dev dependency. npm install runs automatically during setup.

To add further packages:

npm install <package>

Rebuilding

To reset and re-scaffold from scratch, rebuild the container:

  • VS Code: Dev Containers: Rebuild Container
  • Codespaces: Codespaces: Rebuild Container

About

Devcontainer Setup for Marko PHP Framework

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

Contributors

Languages