Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 0 additions & 98 deletions .circleci/config.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG PHP_VERSION=8.1
FROM php:${PHP_VERSION}-cli

RUN groupadd --gid 1000 vscode \
&& useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash vscode \
&& apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get install -y --no-install-recommends \
curl \
git \
libicu-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
unzip \
zip \
&& docker-php-ext-install -j"$(nproc)" bcmath dom intl mbstring soap xml zip \
&& curl -fsSL https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& git config --system --add safe.directory '*' \
&& rm -rf /var/lib/apt/lists/*
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "contentful-core.php",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"PHP_VERSION": "${localEnv:PHP_VERSION:8.1}"
}
},
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"remoteUser": "vscode",
"postCreateCommand": ".devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": [
"bmewburn.vscode-intelephense-client",
"xdebug.php-debug"
]
}
}
}
29 changes: 29 additions & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -euo pipefail

temp_composer="composer.devcontainer.json"
temp_lock="composer.devcontainer.lock"

cleanup() {
rm -f "$temp_composer" "$temp_lock"
}

trap cleanup EXIT

# Install a devcontainer-only dependency set without the BC checker. This repo
# does not commit a lockfile, and roave/backward-compatibility-check can force
# incompatible resolutions during post-create; the dedicated BC CI job still
# exercises that tooling separately.
php <<'PHP'
<?php

$composer = json_decode(file_get_contents('composer.json'), true, 512, JSON_THROW_ON_ERROR);
unset($composer['require-dev']['roave/backward-compatibility-check']);

file_put_contents(
'composer.devcontainer.json',
json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES).PHP_EOL
);
PHP

COMPOSER="$temp_composer" composer install -n --prefer-dist
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
lint-syntax:
name: Lint syntax (PHP 8.1)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli@0

- name: Run syntax checks in dev container
env:
PHP_VERSION: "8.1"
run: |
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash -lc "git ls-files -z '*.php' | xargs -0 -n1 php -l"

static-analysis:
name: Static analysis (PHP 8.1)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli@0

- name: Run static analysis in dev container
env:
PHP_VERSION: "8.1"
run: |
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash -lc "composer run lint-static-analysis"

backwards-compatibility:
name: Backwards compatibility (PHP 8.1)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli@0

- name: Check backwards compatibility in dev container
env:
PHP_VERSION: "8.1"
run: |
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash -lc "composer install -n --prefer-dist && composer run test-for-bc-breaks || true"

test:
name: Test (PHP ${{ matrix.php-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ["8.0", "8.1", "8.2", "8.3", "8.4"]
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Install devcontainer CLI
run: npm install -g @devcontainers/cli@0

- name: Run test suite in dev container
env:
PHP_VERSION: ${{ matrix.php-version }}
run: |
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash -lc "composer test-quick-fail"
32 changes: 0 additions & 32 deletions .github/workflows/codeql.yml

This file was deleted.

39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing

Thanks for helping improve `contentful-core.php`.

## Development with Dev Containers

This repository includes a `.devcontainer` configuration for a reproducible local setup. GitHub Actions uses the same devcontainer configuration for CI.

### Visual Studio Code

Open the repository in Visual Studio Code, install the Dev Containers extension if needed, then run `Dev Containers: Reopen in Container`. Wait for the container build and post-create setup to finish.

### Terminal or other editors

Install Docker and the Dev Container CLI (`npm install -g @devcontainers/cli`). From the repository root, run:

```bash
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash
```

### Verify the environment

```bash
composer test-quick-fail
```

## Other Useful Commands

```bash
composer run lint-static-analysis
composer run test-for-bc-breaks
```

## Pull Requests

1. Fork the repository and create a branch for your change.
2. Run the relevant checks from the dev container.
3. Open a pull request with a short summary of the change and any follow-up context.
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Packagist](https://img.shields.io/packagist/v/contentful/core.svg?style=for-the-badge)](https://packagist.org/packages/contentful/core)
[![PHP from Packagist](https://img.shields.io/packagist/php-v/contentful/core.svg?style=for-the-badge)](https://packagist.org/packages/contentful/core)
[![Packagist](https://img.shields.io/github/license/contentful/contentful-core.php.svg?style=for-the-badge)](https://packagist.org/packages/contentful/core)
<img height="28px" src="https://circleci.com/gh/contentful/contentful-core.php.svg?style=shield"/>
[![CI](https://github.com/contentful/contentful-core.php/actions/workflows/ci.yml/badge.svg)](https://github.com/contentful/contentful-core.php/actions/workflows/ci.yml)

## What is Contentful?

Expand All @@ -17,6 +17,27 @@ This package requires PHP 8.0 or above.

This package provides foundation components for both [Delivery SDK](https://github.com/contentful/contentful.php) and [Management SDK](https://github.com/contentful/contentful-management.php), and it is not meant for being used from third party packages.

## Development with Dev Containers

For a reproducible local setup, this repository includes a `.devcontainer` configuration and GitHub Actions uses the same setup for CI.

In Visual Studio Code, open the repository and run `Dev Containers: Reopen in Container`.

Without Visual Studio Code, install Docker and the Dev Container CLI (`npm install -g @devcontainers/cli`), then run:

```bash
devcontainer up --workspace-folder .
devcontainer exec --workspace-folder . bash
```

After the container is ready, run:

```bash
composer test-quick-fail
```

See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contributor workflow.

## License


Expand Down
2 changes: 1 addition & 1 deletion src/Api/DateTimeImmutable.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function formatForJson(): string
$milliseconds = floor($date->format('u') / 1000);

if ($milliseconds > 0) {
$result .= '.'.mb_str_pad((string) $milliseconds, 3, '0', \STR_PAD_LEFT);
$result .= '.'.str_pad((string) $milliseconds, 3, '0', \STR_PAD_LEFT);
}

return $result.'Z';
Expand Down
2 changes: 1 addition & 1 deletion src/File/UrlOptionsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of the contentful/contentful-core package.
*
* @copyright 2015-2025 Contentful GmbH
* @copyright 2015-2026 Contentful GmbH
* @license MIT
*/

Expand Down
Loading