Skip to content

Commit

Permalink
feat: Add PHP template
Browse files Browse the repository at this point in the history
  • Loading branch information
Sironheart committed Apr 17, 2024
1 parent f638534 commit fb148da
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 0 deletions.
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.

68 changes: 68 additions & 0 deletions template/php/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
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,
...
}: let
inherit (pkgs) dockerTools php83;
inherit (dockerTools) buildImage;
inherit (php83) buildComposerProject;
name = "example";
version = "0.1.0";
phpEnvironment = php83.buildEnv {
extensions = {
enabled,
all,
}:
enabled
++ (with all; [
imagick
opcache
]);

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

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

php = phpEnvironment;

composerLock = ./composer.lock;
};

docker = buildImage {
inherit name;
tag = version;
config = {
Cmd = ["${self'.packages.default}/bin/${name}"];
Env = [
"SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
];
};
};
};
};
};
}
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";

0 comments on commit fb148da

Please sign in to comment.