PHP: Difference between revisions
imported>Drupol No edit summary |
m Category:PHP added |
||
(6 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
__TOC__ | __TOC__ | ||
See also: | |||
* [https://nixos.org/manual/nixpkgs/stable/#ssec-php-user-guide PHP User Guide in the nixpkgs manual]. | |||
* [[phpfpm]] on this wiki | |||
== Install == | == Install == | ||
Line 50: | Line 55: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You can see the full list of extensions e.g. with: | |||
$ nix repl | |||
nix-repl> pkgs = import <nixpkgs> {} | |||
nix-repl> builtins.attrNames pkgs.phpExtensions | |||
== Apache, plugins, settings == | == Apache, plugins, settings == | ||
Line 210: | Line 222: | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Use php Packages with Extensions in a nix-shell == | |||
To use php packages with some extensions enabled, create a <code>shell.nix</code> similar to the following: | |||
<syntaxhighlight lang="nix> | |||
{ pkgs ? import <nixpkgs> { } }: | |||
let | |||
phpEnv = pkgs.php.buildEnv { | |||
extensions = { enabled, all }: enabled ++ (with all; [ xsl ]); | |||
extraConfig = "memory_limit=-1"; | |||
}; | |||
in | |||
pkgs.mkShell { | |||
buildInputs = with pkgs; [ | |||
phpEnv | |||
phpEnv.packages.composer | |||
symfony-cli | |||
]; | |||
} | |||
</syntaxhighlight> | |||
== Troubleshooting == | |||
=== Memcached Extension Isn't Enabled === | |||
Using <code>phpExtensions.memcached</code> inside of <code>environment.systemPackages</code> will lead to the memcached php extension not being enabled in the <code>php.ini</code> file. Here's how to fix it: | |||
<syntaxhighlight lang="nix> | |||
let | |||
# Replace pkgs.php with the php version you want; ex pkgs.php83 | |||
php = pkgs.php.buildEnv { | |||
extensions = { enabled, all }: enabled ++ (with all; [ memcached ]); | |||
}; | |||
in { | |||
environment.systemPackages = with pkgs; [ php ]; | |||
} | |||
</syntaxhighlight> | |||
[[Category:Languages]] | |||
[[Category:PHP]] |