Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add PHP template #63

Merged
merged 2 commits into from
May 24, 2024
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/flake-language.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- nodejs-backend
- nestjs
- ocaml
- php
- powershell
- python-app
- python-pkg
Expand Down Expand Up @@ -53,6 +54,7 @@ jobs:
- nodejs-backend
- nestjs
- ocaml
- php
- powershell
- python-app
- rust
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Kickstart your Nix environments.
- [NestJS](#nestjs)
- [Node.js (backend)](#nodejs-backend)
- [OCaml](#ocaml)
- [PHP](#php)
- [Powershell](#powershell)
- [Python (application)](#python-application)
- [Python (package)](#python-package)
Expand Down Expand Up @@ -400,6 +401,14 @@ Used for OCaml applications.
nix flake init -t github:ALT-F4-LLC/kickstart.nix#ocaml
```

#### PHP

Used for PHP applications

```bash
nix flake init -t github:ALT-F4-LLC/kickstart.nix#php
```

#### Powershell

Used for Powershell applications.
Expand Down
6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
path = ./template/ocaml;
};

php = {
description = "Kickstart PHP application flake.";
path = ./template/php;
};

powershell = {
description = "Kickstart Powershell application flake.";
path = ./template/powershell;
Expand Down Expand Up @@ -162,6 +167,7 @@
example-nixos-minimal = mkNixosMinimal {};
example-nodejs-backend = mkLanguage {name = "nodejs-backend";};
example-ocaml = mkLanguage {name = "ocaml";};
example-php = mkLanguage {name = "php";};
example-powershell = mkLanguage {name = "powershell";};
example-python-app = mkLanguage {name = "python-app";};
example-python-pkg = mkLanguage {name = "python-pkg";};
Expand Down
1 change: 1 addition & 0 deletions template/php/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
23 changes: 23 additions & 0 deletions template/php/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "kickstart-nix/example",
"description": "Example kickstart PHP application project.",
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*"
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
}
}
22 changes: 22 additions & 0 deletions template/php/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions template/php/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
description = "Example kickstart PHP application project.";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin"];

perSystem = {
config,
self',
inputs',
pkgs,
system,
lib,
...
}: let
inherit (pkgs) dockerTools php83 mkShell writeShellApplication;
inherit (lib) getExe;
inherit (dockerTools) buildImage;
inherit (php83) buildComposerProject buildEnv;
name = "example";
version = "0.1.0";
phpEnvironment = buildEnv {
extensions = {
enabled,
all,
}:
enabled
++ (with all; [
imagick
opcache
]);

extraConfig = "memory_limit=256M";
};
in {
devShells = {
default = mkShell {
inputsFrom = [self'.packages.default];
};
};

apps.default = {
type = "app";
program = getExe (writeShellApplication {
inherit name;

runtimeInputs = [
phpEnvironment
];

text = ''
${getExe phpEnvironment} ${self'.packages.default}/share/php/${name}/src/index.php
'';
});
};

packages = {
default = buildComposerProject {
inherit version;
pname = name;
src = ./.;
vendorHash = "sha256-I/uxU1BWb+Uez4dork145EfKKoxHrcUGuyWlps1p628=";

php = phpEnvironment;

composerLock = ./composer.lock;
composerNoDev = false;

preInstall = ''
ls -la
'';
};

docker = buildImage {
inherit name;
tag = version;
config = {
Cmd = ["${self'.apps.default.program}"];
};
};
};
};
};
}
5 changes: 5 additions & 0 deletions template/php/src/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

declare(strict_types=1);

echo "Welcome to PHP";
Loading