Merge remote-tracking branch 'notes/main'

This commit is contained in:
Oliver Davies 2025-08-18 21:19:59 +01:00
commit 9b7fa431f0
5 changed files with 163 additions and 0 deletions

7
Containerfile Normal file
View file

@ -0,0 +1,7 @@
FROM php
COPY index.php /app/index.php
WORKDIR /app
CMD php index.php

27
flake.lock generated Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1755186698,
"narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

21
flake.nix Normal file
View file

@ -0,0 +1,21 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs =
inputs:
let
system = "x86_64-linux";
pkgs = import inputs.nixpkgs { inherit system; };
in
{
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
php
phpPackages.composer
phpactor
];
};
};
}

3
index.php Normal file
View file

@ -0,0 +1,3 @@
<?php
echo "Hi, PHP Thames Valley!";

105
notes.adoc Normal file
View file

@ -0,0 +1,105 @@
= podman
== PHP from the command line
----
podman run --rm php php -v
PHP 8.4.11 (cli) (built: Aug 12 2025 22:28:40) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.11, Copyright (c) Zend Technologies
with Zend OPcache v8.4.11, Copyright (c), by Zend Technologies
----
=== Running a different PHP version
----
podman run --rm php:8.3 php -v
PHP 8.3.24 (cli) (built: Aug 12 2025 22:30:04) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.24, Copyright (c) Zend Technologies
with Zend OPcache v8.3.24, Copyright (c), by Zend Technologies
---
----
=== Running a file
[,shell]
----
podman run --rm -it \
-v $(pwd):/app \
-w /app \
php \
php index.php
----
---
podman build .
STEP 1/2: FROM php
STEP 2/2: CMD php -v
COMMIT
--> d1ec5296cbf0
d1ec5296cbf0da21054b4261a0bb72f66449fe8e8f51b071e53df64e6f83eff4
podman run --rm d1ec5296cbf0
PHP 8.4.11 (cli) (built: Aug 12 2025 22:28:40) (NTS)
Copyright (c) The PHP Group
Built by https://github.com/docker-library/php
Zend Engine v4.4.11, Copyright (c) Zend Technologies
with Zend OPcache v8.4.11, Copyright (c), by Zend Technologies
=== Building a container with code inside
podman build .
STEP 1/4: FROM php
STEP 2/4: COPY index.php /app/index.php
--> b592e9b3b69f
STEP 3/4: WORKDIR /app
--> 8f591440552a
STEP 4/4: CMD php index.php
COMMIT
--> ec4c5890c8a7
ec4c5890c8a75e93e1bb768f998e49ae7d2bf005e5e7c2a57dd2813b881e9758
podman run --rm ec4c5890c8a7
Hi, PHP Thames Valley!
=== Using shell.nix
nix-shell
[nix-shell:~/php-thames-valley]$ php index.php
Hi, PHP Thames Valley
==== Running a command without entering a shell
nix-shell --run "php index.php"
Hi, PHP Thames Valley!
== Adding PHP tools
nix-shell --run "composer --version"
Composer version 2.8.5 2025-01-21 15:23:40
PHP version 8.4.11 (/nix/store/s4kv9bzqawhqcyjg9xm2hji3jap6d6kd-php-with-extensions-8.4.11/bin/php)
nix-shell --run "phpactor --version"
Phpactor 2025.07.25.0
---
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
is the same as
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";