nix-for-php-developers/book/index.adoc

206 lines
3.6 KiB
Text
Raw Permalink Normal View History

2025-08-13 10:20:37 +01:00
[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
2025-08-15 00:53:15 +01:00
:front-cover-image: image:cover.png[fit=fill]
2025-08-13 10:20:37 +01:00
:icons: font
:keywords: php software-development nix linux
:leveloffset: +1
:pygments-linenums-mode: table
:pygments-style: vs
2025-08-15 03:23:37 +01:00
:revdate: {docdatetime}
2025-08-18 20:00:59 +01:00
:revnumber: 0.0.1
2025-08-13 10:20:37 +01:00
:revremark: Under development
:sectlinks:
:sectnums!:
:source-highlighter: pygments
:toc-title: Table of Contents
:toc: left
:toclevels: 2
:xrefstyle: short
2025-08-18 20:08:57 +01:00
_How PHP Developers can create robust and reproducible applications with Nix._
[cols="^.^1,1,1",options="autowidth"]
|===
| https://www.oliverdavies.uk | link:./nix-for-php-developers/opdavies-nix-for-php-developers.pdf[Download PDF] | link:./nix-for-php-developers/opdavies-nix-for-php-developers.epub[Download EPUB]
2025-08-18 20:08:57 +01:00
|===
2025-08-13 10:20:37 +01:00
include::introduction/index.adoc[]
2025-08-14 09:35:01 +01:00
[[installing_php]]
= Other ways to install PHP
2025-08-13 10:20:37 +01:00
////
apt, yum, pacman, etc. System package managers.
Homebrew on macOS and Linux.
Docker, podman, DDEV (containers).
Valet/Herd?
Symfony CLI.
2025-08-14 09:35:01 +01:00
Is there an "official" way on php.net? https://www.php.net/manual/en/install.php
2025-08-13 10:20:37 +01:00
////
Coming soon...
2025-08-14 09:35:01 +01:00
[[different_versions]]
= Different versions of PHP for different projects
2025-08-13 10:20:37 +01:00
////
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...
2025-08-14 09:35:01 +01:00
[[what_nix]]
= What is Nix?
2025-08-13 10:20:37 +01:00
2025-08-14 09:35:01 +01:00
[[nix_language]]
== The language
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[nix_package_manager]]
== The package manager
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[nix_build_tool]]
== The build tool
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[nixos]]
== The operating system (NixOS)
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[nix_benefits]]
= What are the benefits of using Nix?
2025-08-13 10:20:37 +01:00
////
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...
2025-08-14 09:35:01 +01:00
== Reproducible software, not just repeatable
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
== Imperative vs. declarative
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[dev_shells]]
= What are dev shells?
2025-08-13 10:20:37 +01:00
2025-08-15 09:29:23 +01:00
[,nix]
----
# shell.nix
include::../shell.nix[]
----
2025-08-14 09:35:01 +01:00
[[direnv]]
= dev shells and direnv
2025-08-13 10:20:37 +01:00
Using a local flake:
2025-08-15 09:29:23 +01:00
[,bash]
2025-08-13 10:20:37 +01:00
----
use flake .
----
2025-08-14 09:35:01 +01:00
== Remote dev shells
2025-08-13 10:20:37 +01:00
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]
2025-08-15 02:55:56 +01:00
====
2025-08-13 10:20:37 +01:00
If you're referencing a GitHub repository, you can use the shorter `github:username/repo` format instead of the full repository URL.
2025-08-15 02:55:56 +01:00
====
2025-08-13 10:20:37 +01:00
2025-08-14 09:35:01 +01:00
[[what_flakes]]
= What are Flakes?
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[flake_templates]]
== Flake templates
2025-08-13 10:20:37 +01:00
////
flake-utils
flake-parts
////
Coming soon...
2025-08-14 09:35:01 +01:00
[[configuring_php]]
= Configuring PHP with Nix
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[managing_services]]
= Managing services without NixOS
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[building_derivations]]
= Building derivations of PHP applications
2025-08-13 10:20:37 +01:00
Coming soon...
2025-08-14 09:35:01 +01:00
[[nix_composer]]
= Nix vs. Composer
2025-08-13 10:20:37 +01:00
////
composer2nix
////
Coming soon...
2025-08-14 09:35:01 +01:00
= Other usages for Nix
2025-08-13 10:20:37 +01:00
////
Homelab/Server
////
Coming soon...
2025-08-14 09:35:01 +01:00
= Organising Nix configurations
Coming soon...