nix-for-php-developers/book/index.adoc
Oliver Davies b0496042de Automated commit
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
2025-08-18 21:44:48 +01:00

205 lines
3.6 KiB
Text

[separator=::]
= Nix for PHP Developers
:author: Oliver Davies (opdavies)
:copyright: 2025 {author}
:creator: {author}
:description: How to use Nix as a PHP Developer.
:doctype: book
:email: oliver@oliverdavies.uk
:front-cover-image: image:cover.png[fit=fill]
:icons: font
:keywords: php software-development nix linux
:leveloffset: +1
:pygments-linenums-mode: table
:pygments-style: vs
:revdate: {docdatetime}
:revnumber: 0.0.1
:revremark: Under development
:sectlinks:
:sectnums!:
:source-highlighter: pygments
:toc-title: Table of Contents
:toc: left
:toclevels: 2
:xrefstyle: short
_How PHP Developers can create robust and reproducible applications with Nix._
[cols="^.^1,1,1",options="autowidth"]
|===
| https://www.oliverdavies.uk | link:./opdavies-nix-for-php-developers.pdf[Download PDF] | link:./opdavies-nix-for-php-developers.epub[Download EPUB]
|===
include::introduction/index.adoc[]
[[installing_php]]
= Other ways to install PHP
////
apt, yum, pacman, etc. System package managers.
Homebrew on macOS and Linux.
Docker, podman, DDEV (containers).
Valet/Herd?
Symfony CLI.
Is there an "official" way on php.net? https://www.php.net/manual/en/install.php
////
Coming soon...
[[different_versions]]
= Different versions of PHP for different projects
////
Virtual machines.
Vagrant.
Containers.
Valet/Herd. Symfony CLI.
IAC - Ansible, etc.
nvm for PHP?
"virtual" environments, aka. ruby, python.
Why do you need a full operating system?
Why use something specific to a particular framework?
////
Coming soon...
[[what_nix]]
= What is Nix?
[[nix_language]]
== The language
Coming soon...
[[nix_package_manager]]
== The package manager
Coming soon...
[[nix_build_tool]]
== The build tool
Coming soon...
[[nixos]]
== The operating system (NixOS)
Coming soon...
[[nix_benefits]]
= What are the benefits of using Nix?
////
Lightweight.
Simpler - no need for Makefiles or helper scripts.
More native feel.
One tool to work with everything.
Different languages and frameworks.
Agnostic package manager, works on different Linux distros as well as macOS.
Lots of available packages and operating system options.
Ecosystem of tools - e.g. Home Manager.
////
Coming soon...
== Reproducible software, not just repeatable
Coming soon...
== Imperative vs. declarative
Coming soon...
[[dev_shells]]
= What are dev shells?
[,nix]
----
# shell.nix
include::../shell.nix[]
----
[[direnv]]
= dev shells and direnv
Using a local flake:
[,bash]
----
use flake .
----
== Remote dev shells
Using a remote flake:
You can use a `flake.nix` flake in any Git repository, not just the directory you're in.
It can be in a different local directory or a remote Git repository.
For example, you can add this to use the `php84` dev shell within my dev-shells repository:
[source,bash]
----
use flake "git+https://code.oliverdavies.uk/opdavies/dev-shells#php84"
----
This will install PHP 8.4, Composer and Phpactor without needing to create a bespoke `flake.nix`.
[TIP]
====
If you're referencing a GitHub repository, you can use the shorter `github:username/repo` format instead of the full repository URL.
====
[[what_flakes]]
= What are Flakes?
Coming soon...
[[flake_templates]]
== Flake templates
////
flake-utils
flake-parts
////
Coming soon...
[[configuring_php]]
= Configuring PHP with Nix
Coming soon...
[[managing_services]]
= Managing services without NixOS
Coming soon...
[[building_derivations]]
= Building derivations of PHP applications
Coming soon...
[[nix_composer]]
= Nix vs. Composer
////
composer2nix
////
Coming soon...
= Other usages for Nix
////
Homelab/Server
////
Coming soon...
= Organising Nix configurations
Coming soon...