Nextended.Aspire.Hosting.Php
10.1.32
dotnet add package Nextended.Aspire.Hosting.Php --version 10.1.32
NuGet\Install-Package Nextended.Aspire.Hosting.Php -Version 10.1.32
<PackageReference Include="Nextended.Aspire.Hosting.Php" Version="10.1.32" />
<PackageVersion Include="Nextended.Aspire.Hosting.Php" Version="10.1.32" />
<PackageReference Include="Nextended.Aspire.Hosting.Php" />
paket add Nextended.Aspire.Hosting.Php --version 10.1.32
#r "nuget: Nextended.Aspire.Hosting.Php, 10.1.32"
#:package Nextended.Aspire.Hosting.Php@10.1.32
#addin nuget:?package=Nextended.Aspire.Hosting.Php&version=10.1.32
#tool nuget:?package=Nextended.Aspire.Hosting.Php&version=10.1.32
![]()
Nextended.Aspire.Hosting.Php
Run PHP endpoints inside your Aspire stack โ a docroot folder or a single router script served by PHP's built-in web server, with php.ini settings as fluent options.
Runs PHP as an Aspire resource.
๐ Documentation: English ยท Deutsch | ๐งช Runnable sample: Php.AppHost
Run PHP endpoints inside your .NET Aspire stack โ a folder or a single .php file, served by
PHP's built-in web server in the official php:cli container โ and call them from your .NET
services like any other referenced resource.
Quick start
var builder = DistributedApplication.CreateBuilder(args);
// Folder mode: ./php is the docroot, every .php file inside becomes an endpoint.
var php = builder.AddPhp("php", "./php")
.WithPhpIni("memory_limit", "256M")
.WithPhpIni("display_errors", "1");
builder.AddProject<Projects.Api>("api")
.WithReference(php); // service discovery: http://php resolves inside "api"
builder.Build().Run();
Calling it from .NET:
// with Microsoft.Extensions.ServiceDiscovery (standard Aspire service defaults):
var client = new HttpClient { BaseAddress = new Uri("http://php") };
var json = await client.GetStringAsync("/index.php?who=aspire");
await client.PostAsJsonAsync("/send-mail.php", new { to = "x@y.z", subject = "hi" });
Single file mode
Pass a .php file instead of a folder and it becomes the router script โ every request,
regardless of path, is handled by that one file:
builder.AddPhp("mailer", "./php/send-mail.php");
API
| Method | What it does |
|---|---|
AddPhp(name, path, port?, image?, tag?) |
Adds the container. path = folder (docroot) or .php file (router script); relative to the AppHost directory. |
WithPhpIni(key, value) |
One php.ini directive, passed as php -d key=value. |
WithPhpIni(dictionary) |
Several directives at once. |
WithPhpIniConfiguration(a => ...) |
Typed directives: a.DisplayErrors = true, a.MemoryLimit = "256M", a.DateTimezone = "Europe/Berlin", โฆ Subclass PhpIniConfiguration (+ [PhpIniKey("...")]) for anything missing. |
WithPhpIniFile(path) |
Mounts a complete ini file into PHP's conf.d scan dir (overrides the base php.ini). |
WithPhpExtensions("mysqli", ...) |
Installs PHP extensions at container start (docker-php-ext-install). Good for mysqli, pdo_mysql, bcmath, โฆ โ heavier ones (gd, intl) need a custom image. |
WithComposer(image?, tag?) |
Runs composer install (official composer image, same mount) before PHP starts โ vendor/ lands on the host. Folder mode only. |
WithWorkers(n) |
Parallel request workers of the built-in server (PHP_CLI_SERVER_WORKERS, default 8). |
Notes
- Concurrency: the built-in server runs 8 request workers by default; tune with
WithWorkers(n). - Dev server: PHP's built-in server is a development server โ a fine match for Aspire's local orchestration. For production deploys use a proper PHP image (fpm + nginx / apache).
- Extensions: the stock
php:cliimage ships without extras likemysqli/pdo_mysqlโ useWithPhpExtensions(...)(compiled at container start, ~20โ40s) or bake a custom image and pass it viaAddPhp(..., image: "my/php", tag: "dev"). - MySQL: combine with
Aspire.Hosting.MySqlโAddMySql("mysql").WithPhpMyAdmin()gives you the server plus phpMyAdmin; hand PHP the endpoint via.WithEnvironment("MYSQL_URL", mysql.GetEndpoint("tcp"))and addWithPhpExtensions("mysqli"). mail(): the container has no MTA, so PHP'smail()silently no-ops. Speak SMTP instead โ e.g. add a Mailpit container to the stack and hand its endpoint to PHP (.WithEnvironment("SMTP_URL", mailpit.GetEndpoint("smtp"))). ThePhp.AppHosttest project in this repo shows the full pattern including a dependency-free PHP SMTP sender.
Supported frameworks
net8.0net9.0net10.0
Dependencies
- Aspire.Hosting.AppHost
The Nextended family
The other 17 packages in the suite:
Core libraries
- Nextended.Core โ Foundation library โ extension methods, custom types (Money, Date, BaseId, SuperType), class mapping, deep clone, encryption, hashing and the code-generation attributes.
- Nextended.Cache โ Expression-based caching โ automatic cache keys from method expressions, CacheProvider with condition-based invalidation, thread-safe AddOrGetExisting.
Data access
- Nextended.EF โ Entity Framework Core extensions โ graph loading (LoadGraphAsync, IncludeAll, MultiInclude), declarative include definitions, paging, dynamic sorting and bulk operations.
ASP.NET Core & web
- Nextended.Web โ ASP.NET Core utilities โ zero-config OData (AddODataAuto), composable IQueryable OData appliers, strongly typed controller URLs, streaming download helpers and a background executor that can replay a captured request.
- Nextended.ResponseFilters โ Fluent, provider-agnostic pipeline that redacts, masks, rounds, truncates, hashes, prunes and restructures response DTOs before serialization โ per request, per user, per permission.
- Nextended.ResponseFilters.AspNetCore โ ASP.NET Core adapter for Nextended.ResponseFilters โ registers the pipeline as a global IAsyncResultFilter and replays structural edits against the serialized JSON tree.
UI libraries
- Nextended.Blazor โ Blazor helpers โ IBrowserFile extensions (bytes, data URLs, downloads), a hierarchical model for browsing inside uploaded zip/tar/rar archives, MIME-type detection and component-parameter reflection.
- Nextended.UI โ WPF and Windows desktop helpers โ a global input-binding manager with hold/sequence matching, DirectInput and XInput gamepad readers, key-bind capture controls, converters, behaviours, markup extensions and runtime-defined PropertyGrid types.
Code generation & tooling
- Nextended.Imaging โ Image processing โ aspect-preserving resize, crop, colour replacement, brightness-based foreground picking, thumbnail generation, byte/data-URL conversion and MIME detection from magic bytes.
- Nextended.CodeGen โ Roslyn source generator โ DTOs and interfaces from your entities, strongly typed classes from JSON/XML, lookup tables from Excel, and documentation from source files.
.NET Aspire hosting
- Nextended.Aspire โ Conditional AppHost builder extensions โ WithReferenceIf / WaitForIf / WithExplicitStartIf, strongly typed environment variables from config objects, HTTPS dev-cert wiring, Docker guards, GitHub-source resources and npm app discovery.
- Nextended.Aspire.Hosting.Supabase โ The complete Supabase stack โ Postgres, Auth (GoTrue), REST, Realtime, Storage, Studio, Kong and Edge Functions โ as one composable Aspire resource.
- Nextended.Aspire.Hosting.N8n โ The n8n workflow-automation platform as an Aspire resource, with Postgres persistence, workflow import and a typed client for triggering workflows from .NET.
- Nextended.Aspire.Hosting.Grafana โ Grafana, Prometheus, Loki, Tempo, Promtail, cAdvisor, postgres_exporter and the OpenTelemetry Collector as composable resources with auto-provisioned datasources.
- Nextended.Aspire.Hosting.WebDataStudio โ WebDataStudio โ a browser database studio for PostgreSQL, MySQL, SQL Server, SQLite, Oracle, DuckDB, ClickHouse, MongoDB and Redis โ wired to the databases of your stack.
- Nextended.Aspire.Hosting.AspireUI โ AspireUI โ the visual AppHost builder โ as a resource inside your own Aspire stack, with an optional pre-seeded admin user and a starter stack built from your project paths.
- Nextended.Aspire.Hosting.LocalAI โ Self-hosted, OpenAI-compatible multimodal AI โ image generation, text-to-speech, speech-to-text and video โ with gallery model management, GPU support and Open WebUI.
- Nextended.Aspire.Hosting.Php โ Run PHP endpoints inside your Aspire stack โ a docroot folder or a single router script served by PHP's built-in web server, with php.ini settings as fluent options. (this package)
Links
- ๐ฆ NuGet package
- ๐ Documentation โ English
- ๐ Dokumentation โ Deutsch
- ๐ Documentation portal
- ๐งช Runnable sample
- ๐งโ๐ป Source code
- ๐ Report an issue
License
GPL-3.0-or-later โ see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Aspire.Hosting.AppHost (>= 13.5.0)
-
net8.0
- Aspire.Hosting.AppHost (>= 13.5.0)
-
net9.0
- Aspire.Hosting.AppHost (>= 13.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.