Skip to content

Commit 039be3d

Browse files
committed
task: added nix-shell to php-matcher
1 parent 8dc331c commit 039be3d

File tree

15 files changed

+215
-31
lines changed

15 files changed

+215
-31
lines changed

.nix/php/lib/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
php.ini
2+
blackfire.ini
3+
xdebug.ini

.nix/php/lib/blackfire.ini.dist

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[blackfire]
2+
; On Windows use the following configuration:
3+
; extension=php_blackfire.dll
4+
5+
; Sets fine-grained configuration for Probe.
6+
; This should be left blank in most cases. For most installs,
7+
; the server credentials should only be set in the agent.
8+
;blackfire.server_id =
9+
10+
; Sets fine-grained configuration for Probe.
11+
; This should be left blank in most cases. For most installs,
12+
; the server credentials should only be set in the agent.
13+
;blackfire.server_token =
14+
15+
; Log verbosity level:
16+
; 4: debug
17+
; 3: info
18+
; 2: warning;
19+
; 1: error
20+
;blackfire.log_level = 1
21+
22+
; Log file (STDERR by default)
23+
;blackfire.log_file = /tmp/blackfire.log
24+
25+
; Add the stacktrace to the probe logs when a segmentation fault occurs.
26+
; Debug option inactive on Windows and Alpine.
27+
;blackfire.debug.sigsegv_handler = 0
28+
29+
; Sets the socket where the agent is listening.
30+
; Possible value can be a unix socket or a TCP address.
31+
; Defaults values are:
32+
; - Linux: unix:///var/run/blackfire/agent.sock
33+
; - macOS amd64: unix:///usr/local/var/run/blackfire-agent.sock
34+
; - macOS arm64 (M1): unix:///opt/homebrew/var/run/blackfire-agent.sock
35+
; - Windows: tcp://127.0.0.1:8307
36+
;blackfire.agent_socket = unix:///var/run/blackfire/agent.sock
37+
38+
; Enables Blackfire Monitoring
39+
; Enabled by default since version 1.61.0
40+
;blackfire.apm_enabled = 1

.nix/php/lib/pcov.ini.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[pcov]
2+
; pcov.enabled=1
3+
; pcov.directory=.
4+
; pcov.exclude=
5+
; pcov.initial.memory=65536
6+
; pcov.initial.files=64

.nix/php/lib/php.ini.dist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
date.timezone = UTC
2+
max_execution_time = 1800
3+
max_input_time = 3600
4+
max_input_nesting_level = 64
5+
memory_limit = -1
6+
post_max_size = 200M
7+
upload_max_filesize = 150M
8+
file_uploads = On
9+
max_file_uploads = 20
10+
short_open_tag = off

.nix/php/lib/xdebug.ini.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[xdebug]
2+
xdebug.mode=debug

.nix/pkgs/php/package.nix

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
php,
3+
with-pcov ? true,
4+
with-xdebug ? false,
5+
with-blackfire ? false
6+
}:
7+
8+
let
9+
flowPHP = php.withExtensions (
10+
{ enabled, all }:
11+
with all;
12+
enabled
13+
++ [
14+
simplexml
15+
]
16+
++ (if with-xdebug then [xdebug] else [])
17+
++ (if with-pcov then [pcov] else [])
18+
++ (if with-blackfire then [blackfire] else [])
19+
);
20+
in
21+
flowPHP.buildEnv {
22+
extraConfig = ""
23+
+ (
24+
if builtins.pathExists ./../../php/lib/php.ini
25+
then builtins.readFile ./../../php/lib/php.ini
26+
else builtins.readFile ./../../php/lib/php.ini.dist
27+
)
28+
+ "\n"
29+
+ (
30+
if with-xdebug
31+
then
32+
if builtins.pathExists ./../../php/lib/xdebug.ini
33+
then builtins.readFile ./../../php/lib/xdebug.ini
34+
else builtins.readFile ./../../php/lib/xdebug.ini.dist
35+
else ""
36+
)
37+
+ "\n"
38+
+ (
39+
if with-blackfire
40+
then
41+
if builtins.pathExists ./../../php/lib/blackfire.ini
42+
then builtins.readFile ./../../php/lib/blackfire.ini
43+
else builtins.readFile ./../../php/lib/blackfire.ini.dist
44+
else ""
45+
)
46+
+ "\n"
47+
+ (
48+
if with-pcov
49+
then
50+
if builtins.pathExists ./../../php/lib/pcov.ini
51+
then builtins.readFile ./../../php/lib/pcov.ini
52+
else builtins.readFile ./../../php/lib/pcov.ini.dist
53+
else ""
54+
);
55+
}

.nix/shell/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
starship.toml

.nix/shell/starship.toml.dist

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[php]
2+
style = "blue"
3+
format = 'via [$symbol($version )]($style)'
4+
5+
[aws]
6+
disabled = true
7+
[azure]
8+
disabled = true
9+
[gcloud]
10+
disabled = true

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PHPMatcher::error() : ?string;
1414

1515
It was built to simplify API's functional testing.
1616

17-
* [![Test Suite](https://github.com/coduo/php-matcher/actions/workflows/test-suite.yml/badge.svg?branch=6.x)](https://github.com/coduo/php-matcher/actions/workflows/test-suite.yml) - [6.x README](https://github.com/coduo/php-matcher/tree/6.x/README.md) PHP >= 8.1 <= 8.3
17+
* [![Test Suite](https://github.com/coduo/php-matcher/actions/workflows/test-suite.yml/badge.svg?branch=6.x)](https://github.com/coduo/php-matcher/actions/workflows/test-suite.yml) - [6.x README](https://github.com/coduo/php-matcher/tree/6.x/README.md) PHP >= 8.3 <= 8.5
1818
* [5.x README](https://github.com/coduo/php-matcher/tree/5.x/README.md) PHP >= 7.2 < 8.0
1919
* [5.0 README](https://github.com/coduo/php-matcher/tree/5.0/README.md) PHP >= 7.2 < 8.0
2020
* [4.0.* README](https://github.com/coduo/php-matcher/tree/4.0/README.md) PHP >= 7.2 < 8.0

shell.nix

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
let
2+
nixpkgs = fetchTarball {
3+
# Oct 31, 2025
4+
url = "https://github.com/NixOS/nixpkgs/archive/66a437ebcf6160152336e801a7ec289ba2aba3c5.tar.gz";
5+
};
6+
7+
lockedPkgs = import nixpkgs {
8+
config = {
9+
allowUnfree = true;
10+
};
11+
};
12+
in
13+
{
14+
pkgs ? lockedPkgs,
15+
php-version ? 8.3,
16+
with-blackfire ? false,
17+
with-xdebug ? false,
18+
with-pcov ? !with-blackfire
19+
}:
20+
21+
let
22+
base-php = if php-version == 8.3 then
23+
pkgs.php83
24+
else if php-version == 8.4 then
25+
pkgs.php84
26+
else
27+
throw "Unknown php version ${php-version}";
28+
29+
php = pkgs.callPackage ./.nix/pkgs/php/package.nix {
30+
php = base-php;
31+
inherit with-pcov with-xdebug with-blackfire;
32+
};
33+
in
34+
pkgs.mkShell {
35+
buildInputs = [
36+
php
37+
php.packages.composer
38+
pkgs.starship
39+
pkgs.figlet
40+
pkgs.act
41+
]
42+
++ pkgs.lib.optional with-blackfire pkgs.blackfire
43+
;
44+
45+
shellHook = ''
46+
if [ -f "$PWD/.nix/shell/starship.toml" ]; then
47+
export STARSHIP_CONFIG="$PWD/.nix/shell/starship.toml"
48+
else
49+
export STARSHIP_CONFIG="$PWD/.nix/shell/starship.toml.dist"
50+
fi
51+
52+
eval "$(${pkgs.starship}/bin/starship init bash)"
53+
54+
clear
55+
figlet "PHP Matcher"
56+
'';
57+
}

0 commit comments

Comments
 (0)