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.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.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.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[![Packagist](https://img.shields.io/packagist/v/contentful/contentful.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful)
[![PHP version](https://img.shields.io/packagist/php-v/contentful/contentful.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful)
[![Packagist](https://img.shields.io/github/license/contentful/contentful.php.svg?style=for-the-badge)](https://packagist.org/packages/contentful/contentful)
[![CircleCI](https://circleci.com/gh/contentful/contentful.php.svg?style=shield)](https://circleci.com/gh/contentful/contentful.php)
[![CI](https://github.com/contentful/contentful.php/actions/workflows/ci.yml/badge.svg)](https://github.com/contentful/contentful.php/actions/workflows/ci.yml)


> PHP library for the Contentful [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/). It helps you to easily access your Content stored in Contentful with your PHP applications.
Expand Down Expand Up @@ -200,7 +200,15 @@ For details about how to upgrade from version 2.x to version 3, please check the

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?maxAge=31557600)](http://makeapullrequest.com)

**Important**: Right now, the API has `php-vcr` as a development dependency, which does not officially support PHP8 yet. If you want to develop on PHP8, you will need to install the dependencies with `composer install --ignore-platform-reqs` to overwrite this requirement.
For a reproducible local setup, open this repository in its included dev container. The container installs the project dependencies automatically when it is created.

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 composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"test": "vendor/bin/phpunit",
"test-quick-fail": "php vendor/bin/phpunit --stop-on-error --stop-on-failure -v",
"test-for-bc-breaks": "php -d memory_limit=-1 vendor/bin/roave-backward-compatibility-check",
"lint-static-analysis": "php vendor/bin/phpstan analyse src --level=5",
"lint-static-analysis": "php -d memory_limit=-1 vendor/bin/phpstan analyse src --level=5",
"release": "php vendor/contentful/core/scripts/release.php"
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion src/Resource/DeletedAsset.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 package.
*
* @copyright 2015-2025 Contentful GmbH
* @copyright 2015-2026 Contentful GmbH
* @license MIT
*/

Expand Down
Loading