Note: This is a maintained fork of renoki-co/php-k8s with PHP 8.2+ support and additional features. See fork differences for details.
Control your Kubernetes clusters with this PHP-based Kubernetes client. It supports any form of authentication, the exec API, and it has an easy implementation for CRDs.
For Laravel projects, you might want to use renoki-co/laravel-php-k8s (from the upstream project). Note that compatibility with this fork is not guaranteed.
- Full Kubernetes API Support: 33+ resource types including Pods, Deployments, Services, and more
- Exec & Logs: Execute commands and stream logs from containers
- Watch API: Real-time event streaming for resource changes
- JSON Patch & Merge Patch: RFC 6902 and RFC 7396 support for precise updates
- Custom Resources (CRDs): Easy CRD integration with macros
- PHP 8.2+ Modern Features: Enums, type hints, readonly properties, match expressions
- Laravel Integration: First-class Laravel support via laravel-php-k8s
- Flexible Authentication: Kubeconfig, tokens, certificates, in-cluster config
- YAML Import: Load resources directly from YAML files with templating
use RenokiCo\PhpK8s\K8s;
use RenokiCo\PhpK8s\KubernetesCluster;
$cluster = new KubernetesCluster('http://127.0.0.1:8080');
$pod = K8s::pod($cluster)
->setName('my-pod')
->setContainers([
K8s::container()->setName('app')->setImage('nginx:latest')
])
->create();
echo $pod->getName(); // my-pod
echo $pod->getPodPhase(); // Returns PodPhase enum- PHP 8.2 or higher
- Laravel 11.x or 12.x (for Laravel integration)
- Kubernetes cluster access
Read the full documentation at php-k8s.cuppett.dev
This fork is based on renoki-co/php-k8s. See the project history and upstream documentation for more details.
vendor/bin/phpunitPlease see CONTRIBUTING for details.
If you discover any security related issues, please email steve@cuppett.com instead of using the issue tracker.
- Original Author: Alex Renoki
- Fork Maintainer: Stephen Cuppett
- All Contributors