From fb148da63368b088079861d08c93188e98f4225b Mon Sep 17 00:00:00 2001 From: "Beisenherz, Steffen [CBC]" Date: Wed, 17 Apr 2024 10:41:20 +0200 Subject: [PATCH] feat: Add PHP template --- .github/workflows/flake-language.yml | 2 + README.md | 9 ++++ flake.nix | 6 +++ template/php/.gitignore | 1 + template/php/composer.json | 23 ++++++++++ template/php/composer.lock | 22 +++++++++ template/php/flake.nix | 68 ++++++++++++++++++++++++++++ template/php/src/index.php | 5 ++ 8 files changed, 136 insertions(+) create mode 100644 template/php/.gitignore create mode 100644 template/php/composer.json create mode 100644 template/php/composer.lock create mode 100644 template/php/flake.nix create mode 100644 template/php/src/index.php diff --git a/.github/workflows/flake-language.yml b/.github/workflows/flake-language.yml index ebc62e9..50c684f 100644 --- a/.github/workflows/flake-language.yml +++ b/.github/workflows/flake-language.yml @@ -22,6 +22,7 @@ jobs: - nodejs-backend - nestjs - ocaml + - php - powershell - python-app - python-pkg @@ -53,6 +54,7 @@ jobs: - nodejs-backend - nestjs - ocaml + - php - powershell - python-app - rust diff --git a/README.md b/README.md index 05523fd..9c4f033 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. diff --git a/flake.nix b/flake.nix index 95b92c1..2ee3467 100644 --- a/flake.nix +++ b/flake.nix @@ -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; @@ -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";}; diff --git a/template/php/.gitignore b/template/php/.gitignore new file mode 100644 index 0000000..48b8bf9 --- /dev/null +++ b/template/php/.gitignore @@ -0,0 +1 @@ +vendor/ diff --git a/template/php/composer.json b/template/php/composer.json new file mode 100644 index 0000000..e0e84ff --- /dev/null +++ b/template/php/composer.json @@ -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/" + } + } +} diff --git a/template/php/composer.lock b/template/php/composer.lock new file mode 100644 index 0000000..72bfcdc --- /dev/null +++ b/template/php/composer.lock @@ -0,0 +1,22 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "cc26942e91794607415ed3a8f87b768d", + "packages": [], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": true, + "prefer-lowest": false, + "platform": { + "php": ">=8.2", + "ext-ctype": "*", + "ext-iconv": "*" + }, + "platform-dev": [], + "plugin-api-version": "2.6.0" +} diff --git a/template/php/flake.nix b/template/php/flake.nix new file mode 100644 index 0000000..d362bae --- /dev/null +++ b/template/php/flake.nix @@ -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" + ]; + }; + }; + }; + }; + }; +} diff --git a/template/php/src/index.php b/template/php/src/index.php new file mode 100644 index 0000000..4942bd7 --- /dev/null +++ b/template/php/src/index.php @@ -0,0 +1,5 @@ +