├── src
├── Content
│ ├── phpwasm
│ │ ├── PHPScripts
│ │ │ ├── force.php
│ │ │ ├── index.php
│ │ │ └── PHPScripts.msbuildproj
│ │ ├── README.md
│ │ ├── Client
│ │ │ ├── wwwroot
│ │ │ │ └── index.html
│ │ │ ├── Properties
│ │ │ │ └── launchSettings.json
│ │ │ ├── Program.cs
│ │ │ └── Client.csproj
│ │ ├── Server
│ │ │ ├── Server.csproj
│ │ │ ├── Properties
│ │ │ │ └── launchSettings.json
│ │ │ └── Program.cs
│ │ ├── .template.config
│ │ │ └── template.json
│ │ └── MyPHPWebsite.1.sln
│ ├── blazorwasm
│ │ ├── PHPScripts
│ │ │ ├── force.php
│ │ │ ├── index.php
│ │ │ └── PHPScripts.msbuildproj
│ │ ├── Client
│ │ │ ├── Index.razor
│ │ │ ├── App.razor
│ │ │ ├── wwwroot
│ │ │ │ └── index.html
│ │ │ ├── Properties
│ │ │ │ └── launchSettings.json
│ │ │ ├── BlazorApp.Client.csproj
│ │ │ └── Program.cs
│ │ ├── README.md
│ │ ├── Server
│ │ │ ├── BlazorApp.Server.csproj
│ │ │ ├── Properties
│ │ │ │ └── launchSettings.json
│ │ │ └── Program.cs
│ │ ├── .template.config
│ │ │ └── template.json
│ │ └── MyPHPWebsite.1.sln
│ ├── web
│ │ ├── Website
│ │ │ ├── index.php
│ │ │ └── Website.msbuildproj
│ │ ├── README.md
│ │ ├── Server
│ │ │ ├── Server.csproj
│ │ │ └── Program.cs
│ │ ├── .template.config
│ │ │ └── template.json
│ │ └── MyWebsite.1.sln
│ ├── console
│ │ ├── program.php
│ │ ├── README.md
│ │ ├── PhpConsole.1.msbuildproj
│ │ └── .template.config
│ │ │ └── template.json
│ └── classlib
│ │ ├── lib.php
│ │ ├── README.md
│ │ ├── PhpLib.1.msbuildproj
│ │ └── .template.config
│ │ └── template.json
├── readme.md
└── Peachpie.Templates.nuspec
├── tests
├── readme.md
└── test.ps1
├── tools
└── nuget.exe
├── myget.ps1
├── .gitattributes
├── readme.md
└── .gitignore
/src/Content/phpwasm/PHPScripts/force.php:
--------------------------------------------------------------------------------
1 | Hello, world from PHP!
";
--------------------------------------------------------------------------------
/src/Content/web/Website/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | PHP WEB
5 |
6 |
7 |
8 | Hello from PHP!";
10 | ?>
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Content/classlib/lib.php:
--------------------------------------------------------------------------------
1 |
2 |
3 | library
4 | net6.0
5 | false
6 |
7 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/PHPScripts/PHPScripts.msbuildproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | library
4 | net6.0
5 | false
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Content/web/README.md:
--------------------------------------------------------------------------------
1 | ## web-app
2 |
3 | Template for a simple PHP web application hosten on Kestrel and ASP.NET Core pipeline.
4 |
5 | ### How to run
6 | 1. Install peachpie templates
7 | 2. `dotnet new web -lang PHP`
8 | 3. `dotnet restore`
9 | 4. Modify `Website/index.php` (optional)
10 | 5. `cd Server`
11 | 6. `dotnet run`
--------------------------------------------------------------------------------
/src/Content/web/Server/Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Client/Index.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 | @using Peachpie.Blazor
3 |
4 | Hello, world from C#!
5 |
6 |
7 |
8 | Navigating
9 |
10 |
11 | Script not found
12 |
13 |
--------------------------------------------------------------------------------
/src/Content/classlib/README.md:
--------------------------------------------------------------------------------
1 | ## web-app
2 |
3 | Template for a dotnet class library written in PHP. Code from all .php files gets compiled into one .NET assembly that can be referenced from any .NET project, be it C#, F#, VB, or - thanks to Peachpie - PHP.
4 |
5 | ### How to run
6 | 1. Install peachpie templates
7 | 2. `dotnet new classlib -lang PHP`
8 | 3. `dotnet restore`
9 | 4. Modify `lib.php` (optional)
10 | 5. `dotnet build`
11 |
--------------------------------------------------------------------------------
/src/Content/phpwasm/README.md:
--------------------------------------------------------------------------------
1 | ## phpwasm
2 |
3 | Template for running PHP scripts on a client side by Blazor. The template contains a Blazor web application, which is created just from PHP scripts.
4 |
5 | ### How to run
6 |
7 | 1. Install peachpie templates
8 | 2. `dotnet new phpwasm -lang PHP`
9 | 3. `dotnet restore`
10 | 4. Modify `PHPScripts` library (PHP) (optional)
11 | 5. `dotnet build`
12 | 6. `dotnet run --project BlazorApp\Server`
13 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Client/App.razor:
--------------------------------------------------------------------------------
1 | @namespace MyPHPWebsite.1.Client
2 |
3 |
4 |
5 |
6 |
7 |
8 | Sorry, there's nothing at this address.
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/src/Content/phpwasm/Client/wwwroot/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | PeachPieBlazorApp
8 |
9 |
10 |
11 |
12 | Loading...
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Content/console/PhpConsole.1.msbuildproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Exe
5 | net6.0
6 | program.php
7 | Simpliest PHP project for .NET Core, a console application.
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Client/wwwroot/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | PeachPieBlazorApp
8 |
9 |
10 |
11 |
12 | Loading...
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/README.md:
--------------------------------------------------------------------------------
1 | ## blazorwasm
2 |
3 | Template for running PHP scripts on a client side by Blazor. The template contains a Blazor web application with Razor pages and pages generated from PHP scripts.
4 |
5 | ### How to run
6 | 1. Install peachpie templates
7 | 2. `dotnet new blazorwasm -lang PHP`
8 | 3. `dotnet restore`
9 | 4. Modify `PHPScripts` library (PHP) or ```Blazor.Client``` (Razor) (optional)
10 | 5. `dotnet build`
11 | 6. `dotnet run --project BlazorApp\Server`
12 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Server/BlazorApp.Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Content/classlib/PhpLib.1.msbuildproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 | net6.0
6 | .NET class library in PHP
7 | PhpLib1
8 | True
9 | true
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Content/phpwasm/Server/Server.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Client/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "BlazorApp.Server": {
4 | "commandName": "Project",
5 | "dotnetRunMessages": "true",
6 | "launchBrowser": true,
7 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
8 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
9 | "environmentVariables": {
10 | "ASPNETCORE_ENVIRONMENT": "Development"
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Server/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "BlazorApp.Server": {
4 | "commandName": "Project",
5 | "dotnetRunMessages": "true",
6 | "launchBrowser": true,
7 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
8 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
9 | "environmentVariables": {
10 | "ASPNETCORE_ENVIRONMENT": "Development"
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Content/phpwasm/Client/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "BlazorApp.Server": {
4 | "commandName": "Project",
5 | "dotnetRunMessages": "true",
6 | "launchBrowser": true,
7 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
8 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
9 | "environmentVariables": {
10 | "ASPNETCORE_ENVIRONMENT": "Development"
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Content/phpwasm/Server/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "BlazorApp.Server": {
4 | "commandName": "Project",
5 | "dotnetRunMessages": "true",
6 | "launchBrowser": true,
7 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
8 | "applicationUrl": "https://localhost:5001;http://localhost:5000",
9 | "environmentVariables": {
10 | "ASPNETCORE_ENVIRONMENT": "Development"
11 | }
12 | }
13 | }
14 | }
--------------------------------------------------------------------------------
/src/Content/classlib/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Peachpie",
4 | "classifications": [ "Common", "Library" ],
5 | "name": "Class library",
6 | "description": "A project for creating a class library that targets .NET Standard or .NET Core",
7 | "groupIdentity": "Microsoft.Common.Library",
8 | "identity": "Peachpie.Templates.ClassLibrary",
9 | "shortName": "classlib",
10 | "sourceName": "PhpLib.1",
11 | "preferNameDirectory" : "true",
12 | "tags": {
13 | "language": "PHP",
14 | "type": "project"
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Content/phpwasm/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Tomas Husak",
4 | "classifications": [ "Web", "Blazor" , "WebAssembly" ],
5 | "name": "PHP WebAssembly App",
6 | "description": "A simple website template for creating an Peachpie-Blazor application.",
7 | "groupIdentity": "Peachpie.Blazor.Templates.Web",
8 | "identity": "Peachpie.Blazor.Templates.Web",
9 | "shortName": "phpwasm",
10 | "sourceName": "MyPHPWebsite.1",
11 | "preferNameDirectory" : true,
12 | "tags": {
13 | "language": "PHP",
14 | "type": "project"
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Content/web/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Peachpie",
4 | "classifications": [ "Web", "Empty" ],
5 | "name": "ASP.NET Core Empty",
6 | "description": "An empty project template for creating an ASP.NET Core application. This template does not have any content in it.",
7 | "groupIdentity": "Microsoft.Web.Empty",
8 | "identity": "Peachpie.Templates.WebApp",
9 | "shortName": "web",
10 | "sourceName": "MyWebsite.1",
11 | "preferNameDirectory" : true,
12 | "tags": {
13 | "language": "PHP",
14 | "type": "project"
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Content/web/Website/Website.msbuildproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Library
5 | net6.0
6 | MyWebsite.1
7 |
8 |
9 |
10 |
13 |
16 | PreserveNewest
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/Content/console/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Peachpie",
4 | "classifications": [ "Common", "Console" ],
5 | "name": "Console Application",
6 | "description": "A project for creating a command-line application that can run on .NET Core on Windows, Linux and macOS",
7 | "groupIdentity": "Microsoft.Common.Console",
8 | "identity": "Peachpie.Templates.ConsoleApp",
9 | "shortName": "console",
10 | "sourceName": "PhpConsole.1",
11 | "defaultName": "ConsoleApp1",
12 | "preferNameDirectory" : true,
13 | "tags": {
14 | "language": "PHP",
15 | "type": "project"
16 | }
17 | }
--------------------------------------------------------------------------------
/src/Content/blazorwasm/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Tomas Husak",
4 | "classifications": [ "Web", "Blazor" , "WebAssembly" ],
5 | "name": "PHP Blazor WebAssembly App",
6 | "description": "A simple website template for creating an Peachpie-Blazor application combining Razor pages and PHP scripts.",
7 | "groupIdentity": "Microsoft.Web.Blazor.Wasm",
8 | "identity": "Peachpie.Templates.Blazor.Hybrid",
9 | "shortName": "blazorwasm",
10 | "sourceName": "MyPHPWebsite.1",
11 | "preferNameDirectory" : "true",
12 | "tags": {
13 | "language": "PHP",
14 | "type": "project"
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Client/BlazorApp.Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Content/phpwasm/Client/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
2 | using Microsoft.Extensions.Logging;
3 | using Peachpie.Blazor;
4 | using System.Threading.Tasks;
5 |
6 | namespace MyPHPWebsite.1.Client
7 | {
8 | public class Program
9 | {
10 | public static async Task Main(string[] args)
11 | {
12 | var builder = WebAssemblyHostBuilder.CreateDefault(args);
13 |
14 | // uncomment to remove logging
15 | // builder.Logging.SetMinimumLevel(LogLevel.None);
16 |
17 | // Add PHP
18 | builder.AddPhp(new[] { typeof(force).Assembly });
19 | builder.RootComponents.Add(typeof(PhpScriptProvider), "#app");
20 |
21 | await builder.Build().RunAsync();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Peachpie.Templates.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Peachpie.Templates
5 | 1.1.13
6 | Templates of PHP projects for .NET platform using PeachPie Compiler.
7 | peachpie, Petr Houska, Jakub Misek
8 | en-US
9 | https://github.com/peachpiecompiler/peachpie
10 | https://github.com/peachpiecompiler/peachpie/blob/master/LICENSE.txt
11 | Copyright 2025. All right Reserved.
12 | true
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Client/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Microsoft.Extensions.Logging;
5 | using System;
6 | using System.Collections.Generic;
7 | using Peachpie.Blazor;
8 | using System.Threading.Tasks;
9 |
10 | namespace MyPHPWebsite.1.Client
11 | {
12 | public class Program
13 | {
14 | public static async Task Main(string[] args)
15 | {
16 | var builder = WebAssemblyHostBuilder.CreateDefault(args);
17 | builder.RootComponents.Add("#app");
18 |
19 | // uncomment to remove logging
20 | // builder.Logging.SetMinimumLevel(LogLevel.None);
21 |
22 | builder.AddPhp(new[] { typeof(force).Assembly});
23 |
24 |
25 | await builder.Build().RunAsync();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/test.ps1:
--------------------------------------------------------------------------------
1 | # install templates
2 | dotnet new --debug:reinit
3 | dotnet new -i "$PSScriptRoot/../out/Peachpie.Templates.*.nupkg"
4 |
5 | # prepare folder for templates testing
6 | mkdir "$PSScriptRoot/../tmp"
7 | Set-Location "$PSScriptRoot/../tmp"
8 |
9 | # get all available templates
10 | $templates = Get-ChildItem -dir "$PSScriptRoot/../src/Content"
11 |
12 | $error = 0;
13 |
14 | # for each template create its project, restore it, and build it
15 | foreach($template in $templates){
16 | Remove-Item "./*" -Recurse -Force
17 |
18 | dotnet new $template.Name
19 | if(!($?)) { $error += 1; continue }
20 | dotnet restore
21 | if(!($?)) { $error += 1; continue }
22 | dotnet build
23 | if(!($?)) { $error += 1; continue }
24 | }
25 |
26 | # remove tmp folder
27 | Set-Location "$PSScriptRoot/.."
28 | Remove-Item "./tmp" -Force -Recurse
29 |
30 | Write-Output "Number of errored templates: $error"
31 | exit $error
--------------------------------------------------------------------------------
/src/Content/phpwasm/Client/Client.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | wwwroot\%(RecursiveDir)/%(FileName)%(Extension)
18 | PreserveNewest
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/src/Content/phpwasm/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.Extensions.Hosting;
4 |
5 | namespace MyPHPWebsite.1.Server
6 | {
7 | public class Program
8 | {
9 | public static void Main(string[] args)
10 | {
11 | CreateHostBuilder(args).Build().Run();
12 | }
13 |
14 | public static IHostBuilder CreateHostBuilder(string[] args) =>
15 | Host.CreateDefaultBuilder(args)
16 | .ConfigureWebHostDefaults(webBuilder =>
17 | {
18 | webBuilder.UseStartup();
19 | });
20 | }
21 |
22 | public class Startup
23 | {
24 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
25 | {
26 | if (env.IsDevelopment())
27 | app.UseWebAssemblyDebugging();
28 |
29 | app.UseBlazorFrameworkFiles();
30 | app.UseStaticFiles();
31 |
32 | app.UseRouting();
33 |
34 | app.UseEndpoints(endpoints =>
35 | {
36 | endpoints.MapFallbackToFile("index.html");
37 | endpoints.MapFallbackToFile("/{**.php}", "index.html");
38 | });
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.Extensions.Hosting;
4 |
5 | namespace MyPHPWebsite.1.Server
6 | {
7 | public class Program
8 | {
9 | public static void Main(string[] args)
10 | {
11 | CreateHostBuilder(args).Build().Run();
12 | }
13 |
14 | public static IHostBuilder CreateHostBuilder(string[] args) =>
15 | Host.CreateDefaultBuilder(args)
16 | .ConfigureWebHostDefaults(webBuilder =>
17 | {
18 | webBuilder.UseStartup();
19 | });
20 | }
21 |
22 | public class Startup
23 | {
24 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
25 | {
26 | if (env.IsDevelopment())
27 | app.UseWebAssemblyDebugging();
28 |
29 | app.UseBlazorFrameworkFiles();
30 | app.UseStaticFiles();
31 |
32 | app.UseRouting();
33 |
34 | app.UseEndpoints(endpoints =>
35 | {
36 | endpoints.MapFallbackToFile("index.html");
37 | endpoints.MapFallbackToFile("/{**.php}", "index.html");
38 | });
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | ## PeachPie Templates
2 |
3 | This repository contains various `dotnet` project templates to be used for creating PeachPie compiled applications.
4 |
5 | ## Using templates
6 |
7 | 0. Install peachpie templates via: `dotnet new -i "Peachpie.Templates::*"`
8 | 1. Create a project based on chosen template e.g.: `dotnet new console -lang PHP`
9 | 2. Restore packages for the newly created project: `dotnet restore`
10 | 3. Run the project: `dotnet run`
11 |
12 | > You need to install PeachPie templates only once. They get stored in ~HOME/.templateengine cache.
13 |
14 | ## Prerequisites
15 |
16 | - .NET SDK 6.0 or later
17 | - PowerShell (only for building)
18 |
19 | ## Contributing templates & building
20 |
21 | ### Adding a new template:
22 |
23 | - Go to `./src/Content`
24 | - Create a new folder with name mathing the template's `shortName`
25 | - Fill the folder with all that is required for a template
26 | - [Official documentation on template creation](https://github.com/dotnet/templating/wiki/%22Runnable-Project%22-Templates)
27 | - [Tutorial on MSDN](https://blogs.msdn.microsoft.com/dotnet/2017/04/02/how-to-create-your-own-templates-for-dotnet-new/)
28 | - [Short introduction on rehansaeed.com](http://rehansaeed.com/custom-project-templates-using-dotnet-new/)
29 |
30 | ### Building & testing
31 |
32 | - Invoke `.\build.ps1` which calls a [build](https://github.com/peachpiecompiler/peachpie-templates/tree/master/build/build.ps1) (1) and a [test](https://github.com/peachpiecompiler/peachpie-templates/tree/master/tests/test.ps1) (2) script
33 | - 1: Packages all templates into a nuget package (see `/out/Peachpie.Templates.x.y.z.nupkg`)
34 | - 2: Installs the the templates package to current `.templateengine` cache
35 | - 2: Tries to create a project from each one, restore it, and build it
36 | - After invoking the build script your template should be listed among `dotnet new -all`
37 |
38 |
--------------------------------------------------------------------------------
/src/Content/phpwasm/MyPHPWebsite.1.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31605.320
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{059EF486-DE6A-4A48-AF61-55EEDEE16815}"
7 | EndProject
8 | Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "PHPScripts", "PHPScripts\PHPScripts.msbuildproj", "{70E556DA-E4E0-483E-B493-06AF532653ED}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{DFC33DD0-9F3A-4A2A-BAF4-04537E20C75D}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {059EF486-DE6A-4A48-AF61-55EEDEE16815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {059EF486-DE6A-4A48-AF61-55EEDEE16815}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {059EF486-DE6A-4A48-AF61-55EEDEE16815}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {059EF486-DE6A-4A48-AF61-55EEDEE16815}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {70E556DA-E4E0-483E-B493-06AF532653ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {70E556DA-E4E0-483E-B493-06AF532653ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {70E556DA-E4E0-483E-B493-06AF532653ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {70E556DA-E4E0-483E-B493-06AF532653ED}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {DFC33DD0-9F3A-4A2A-BAF4-04537E20C75D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {DFC33DD0-9F3A-4A2A-BAF4-04537E20C75D}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {DFC33DD0-9F3A-4A2A-BAF4-04537E20C75D}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {DFC33DD0-9F3A-4A2A-BAF4-04537E20C75D}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {6E295449-F228-4630-BF24-AF174081200F}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/src/Content/blazorwasm/MyPHPWebsite.1.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31019.35
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorApp.Server", "Server\BlazorApp.Server.csproj", "{C1022385-D1F9-4B58-87D2-37FF212F94E9}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorApp.Client", "Client\BlazorApp.Client.csproj", "{3B259BC3-DC88-4971-AD5F-1573061495F2}"
9 | EndProject
10 | Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "PHPScripts", "PHPScripts\PHPScripts.msbuildproj", "{D625D308-644B-40C0-8592-A741C0C303B9}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {C1022385-D1F9-4B58-87D2-37FF212F94E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {C1022385-D1F9-4B58-87D2-37FF212F94E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {C1022385-D1F9-4B58-87D2-37FF212F94E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {C1022385-D1F9-4B58-87D2-37FF212F94E9}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {3B259BC3-DC88-4971-AD5F-1573061495F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {3B259BC3-DC88-4971-AD5F-1573061495F2}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {3B259BC3-DC88-4971-AD5F-1573061495F2}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {3B259BC3-DC88-4971-AD5F-1573061495F2}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {D625D308-644B-40C0-8592-A741C0C303B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {D625D308-644B-40C0-8592-A741C0C303B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {D625D308-644B-40C0-8592-A741C0C303B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {D625D308-644B-40C0-8592-A741C0C303B9}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {29AF6906-7348-45E0-946A-516BE387F8DD}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/src/Content/web/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using Microsoft.AspNetCore;
4 | using Microsoft.AspNetCore.Builder;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.FileProviders;
8 | using Microsoft.Extensions.Hosting;
9 |
10 | namespace MyWebsite.1.Server
11 | {
12 | class Program
13 | {
14 | static void Main(string[] args)
15 | {
16 | var host = WebHost.CreateDefaultBuilder(args)
17 | .UseStartup()
18 | .UseUrls("http://*:5004/")
19 | .Build();
20 |
21 | host.Run();
22 | }
23 | }
24 |
25 | class Startup
26 | {
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 | // Adds a default in-memory implementation of IDistributedCache.
30 | services.AddDistributedMemoryCache();
31 |
32 | services.AddSession(options =>
33 | {
34 | options.IdleTimeout = TimeSpan.FromMinutes(30);
35 | options.Cookie.HttpOnly = true;
36 | });
37 |
38 | services.AddPhp(options =>
39 | {
40 | //
41 | });
42 | }
43 |
44 | public void Configure(IApplicationBuilder app, IHostEnvironment env)
45 | {
46 | //// sample usage of URL rewrite:
47 | //var options = new RewriteOptions()
48 | // .AddRewrite(@"^rule/(\w+)", "index.php?word=$1", skipRemainingRules: true);
49 |
50 | //app.UseRewriter(options);
51 |
52 | // enable session:
53 | app.UseSession();
54 |
55 | // enable .php files from compiled assembly:
56 | var contentPath = ResolveContentPath();
57 |
58 | app.UsePhp("/", rootPath: contentPath);
59 | app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(contentPath) });
60 |
61 | //
62 | app.UseDefaultFiles();
63 | app.UseStaticFiles();
64 | }
65 |
66 | ///
67 | /// Gets location of website project content.
68 | /// In development, we use the original website project location.
69 | /// Otherwise, content files are published to the current working directory.
70 | ///
71 | ///
72 | static string ResolveContentPath()
73 | {
74 | var devcontent = Path.GetFullPath("../Website");
75 | if (Directory.Exists(devcontent))
76 | {
77 | return devcontent;
78 | }
79 |
80 | return Directory.GetCurrentDirectory();
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/src/Content/web/MyWebsite.1.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26124.0
5 | MinimumVisualStudioVersion = 15.0.26124.0
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Website", "Website\Website.msbuildproj", "{A271793F-72BF-429D-9EC8-83C03559CBD6}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "Server\Server.csproj", "{AF5D53C1-32B5-473F-9229-817608068701}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|x64 = Debug|x64
14 | Debug|x86 = Debug|x86
15 | Release|Any CPU = Release|Any CPU
16 | Release|x64 = Release|x64
17 | Release|x86 = Release|x86
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
23 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
25 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x64.ActiveCfg = Debug|x64
26 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x64.Build.0 = Debug|x64
27 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x86.ActiveCfg = Debug|x86
28 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Debug|x86.Build.0 = Debug|x86
29 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
30 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|Any CPU.Build.0 = Release|Any CPU
31 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x64.ActiveCfg = Release|x64
32 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x64.Build.0 = Release|x64
33 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x86.ActiveCfg = Release|x86
34 | {A271793F-72BF-429D-9EC8-83C03559CBD6}.Release|x86.Build.0 = Release|x86
35 | {AF5D53C1-32B5-473F-9229-817608068701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36 | {AF5D53C1-32B5-473F-9229-817608068701}.Debug|Any CPU.Build.0 = Debug|Any CPU
37 | {AF5D53C1-32B5-473F-9229-817608068701}.Debug|x64.ActiveCfg = Debug|x64
38 | {AF5D53C1-32B5-473F-9229-817608068701}.Debug|x64.Build.0 = Debug|x64
39 | {AF5D53C1-32B5-473F-9229-817608068701}.Debug|x86.ActiveCfg = Debug|x86
40 | {AF5D53C1-32B5-473F-9229-817608068701}.Debug|x86.Build.0 = Debug|x86
41 | {AF5D53C1-32B5-473F-9229-817608068701}.Release|Any CPU.ActiveCfg = Release|Any CPU
42 | {AF5D53C1-32B5-473F-9229-817608068701}.Release|Any CPU.Build.0 = Release|Any CPU
43 | {AF5D53C1-32B5-473F-9229-817608068701}.Release|x64.ActiveCfg = Release|x64
44 | {AF5D53C1-32B5-473F-9229-817608068701}.Release|x64.Build.0 = Release|x64
45 | {AF5D53C1-32B5-473F-9229-817608068701}.Release|x86.ActiveCfg = Release|x86
46 | {AF5D53C1-32B5-473F-9229-817608068701}.Release|x86.Build.0 = Release|x86
47 | EndGlobalSection
48 | EndGlobal
49 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # Added
7 | [Oo]ut
8 | [Tt]mp
9 |
10 | # User-specific files
11 | *.suo
12 | *.user
13 | *.userosscache
14 | *.sln.docstates
15 |
16 | # User-specific files (MonoDevelop/Xamarin Studio)
17 | *.userprefs
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | bld/
27 | [Bb]in/
28 | [Oo]bj/
29 | [Ll]og/
30 |
31 | # Visual Studio 2015 cache/options directory
32 | .vs/
33 | # Uncomment if you have tasks that create the project's static files in wwwroot
34 | #wwwroot/
35 |
36 | # MSTest test Results
37 | [Tt]est[Rr]esult*/
38 | [Bb]uild[Ll]og.*
39 |
40 | # NUNIT
41 | *.VisualState.xml
42 | TestResult.xml
43 |
44 | # Build Results of an ATL Project
45 | [Dd]ebugPS/
46 | [Rr]eleasePS/
47 | dlldata.c
48 |
49 | # Benchmark Results
50 | BenchmarkDotNet.Artifacts/
51 |
52 | # .NET Core
53 | project.lock.json
54 | project.fragment.lock.json
55 | artifacts/
56 |
57 | *_i.c
58 | *_p.c
59 | *_i.h
60 | *.ilk
61 | *.meta
62 | *.obj
63 | *.pch
64 | *.pdb
65 | *.pgc
66 | *.pgd
67 | *.rsp
68 | *.sbr
69 | *.tlb
70 | *.tli
71 | *.tlh
72 | *.tmp
73 | *.tmp_proj
74 | *.log
75 | *.vspscc
76 | *.vssscc
77 | .builds
78 | *.pidb
79 | *.svclog
80 | *.scc
81 |
82 | # Chutzpah Test files
83 | _Chutzpah*
84 |
85 | # Visual C++ cache files
86 | ipch/
87 | *.aps
88 | *.ncb
89 | *.opendb
90 | *.opensdf
91 | *.sdf
92 | *.cachefile
93 | *.VC.db
94 | *.VC.VC.opendb
95 |
96 | # Visual Studio profiler
97 | *.psess
98 | *.vsp
99 | *.vspx
100 | *.sap
101 |
102 | # TFS 2012 Local Workspace
103 | $tf/
104 |
105 | # Guidance Automation Toolkit
106 | *.gpState
107 |
108 | # ReSharper is a .NET coding add-in
109 | _ReSharper*/
110 | *.[Rr]e[Ss]harper
111 | *.DotSettings.user
112 |
113 | # JustCode is a .NET coding add-in
114 | .JustCode
115 |
116 | # TeamCity is a build add-in
117 | _TeamCity*
118 |
119 | # DotCover is a Code Coverage Tool
120 | *.dotCover
121 |
122 | # Visual Studio code coverage results
123 | *.coverage
124 | *.coveragexml
125 |
126 | # NCrunch
127 | _NCrunch_*
128 | .*crunch*.local.xml
129 | nCrunchTemp_*
130 |
131 | # MightyMoose
132 | *.mm.*
133 | AutoTest.Net/
134 |
135 | # Web workbench (sass)
136 | .sass-cache/
137 |
138 | # Installshield output folder
139 | [Ee]xpress/
140 |
141 | # DocProject is a documentation generator add-in
142 | DocProject/buildhelp/
143 | DocProject/Help/*.HxT
144 | DocProject/Help/*.HxC
145 | DocProject/Help/*.hhc
146 | DocProject/Help/*.hhk
147 | DocProject/Help/*.hhp
148 | DocProject/Help/Html2
149 | DocProject/Help/html
150 |
151 | # Click-Once directory
152 | publish/
153 |
154 | # Publish Web Output
155 | *.[Pp]ublish.xml
156 | *.azurePubxml
157 | # TODO: Comment the next line if you want to checkin your web deploy settings
158 | # but database connection strings (with potential passwords) will be unencrypted
159 | *.pubxml
160 | *.publishproj
161 |
162 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
163 | # checkin your Azure Web App publish settings, but sensitive information contained
164 | # in these scripts will be unencrypted
165 | PublishScripts/
166 |
167 | # NuGet Packages
168 | *.nupkg
169 | # The packages folder can be ignored because of Package Restore
170 | **/packages/*
171 | # except build/, which is used as an MSBuild target.
172 | !**/packages/build/
173 | # Uncomment if necessary however generally it will be regenerated when needed
174 | #!**/packages/repositories.config
175 | # NuGet v3's project.json files produces more ignorable files
176 | *.nuget.props
177 | *.nuget.targets
178 |
179 | # Microsoft Azure Build Output
180 | csx/
181 | *.build.csdef
182 |
183 | # Microsoft Azure Emulator
184 | ecf/
185 | rcf/
186 |
187 | # Windows Store app package directories and files
188 | AppPackages/
189 | BundleArtifacts/
190 | Package.StoreAssociation.xml
191 | _pkginfo.txt
192 | *.appx
193 |
194 | # Visual Studio cache files
195 | # files ending in .cache can be ignored
196 | *.[Cc]ache
197 | # but keep track of directories ending in .cache
198 | !*.[Cc]ache/
199 |
200 | # Others
201 | ClientBin/
202 | ~$*
203 | *~
204 | *.dbmdl
205 | *.dbproj.schemaview
206 | *.jfm
207 | *.pfx
208 | *.publishsettings
209 | orleans.codegen.cs
210 |
211 | # Since there are multiple workflows, uncomment next line to ignore bower_components
212 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
213 | #bower_components/
214 |
215 | # RIA/Silverlight projects
216 | Generated_Code/
217 |
218 | # Backup & report files from converting an old project file
219 | # to a newer Visual Studio version. Backup files are not needed,
220 | # because we have git ;-)
221 | _UpgradeReport_Files/
222 | Backup*/
223 | UpgradeLog*.XML
224 | UpgradeLog*.htm
225 |
226 | # SQL Server files
227 | *.mdf
228 | *.ldf
229 | *.ndf
230 |
231 | # Business Intelligence projects
232 | *.rdl.data
233 | *.bim.layout
234 | *.bim_*.settings
235 |
236 | # Microsoft Fakes
237 | FakesAssemblies/
238 |
239 | # GhostDoc plugin setting file
240 | *.GhostDoc.xml
241 |
242 | # Node.js Tools for Visual Studio
243 | .ntvs_analysis.dat
244 | node_modules/
245 |
246 | # Typescript v1 declaration files
247 | typings/
248 |
249 | # Visual Studio 6 build log
250 | *.plg
251 |
252 | # Visual Studio 6 workspace options file
253 | *.opt
254 |
255 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
256 | *.vbw
257 |
258 | # Visual Studio LightSwitch build output
259 | **/*.HTMLClient/GeneratedArtifacts
260 | **/*.DesktopClient/GeneratedArtifacts
261 | **/*.DesktopClient/ModelManifest.xml
262 | **/*.Server/GeneratedArtifacts
263 | **/*.Server/ModelManifest.xml
264 | _Pvt_Extensions
265 |
266 | # Paket dependency manager
267 | .paket/paket.exe
268 | paket-files/
269 |
270 | # FAKE - F# Make
271 | .fake/
272 |
273 | # JetBrains Rider
274 | .idea/
275 | *.sln.iml
276 |
277 | # CodeRush
278 | .cr/
279 |
280 | # Python Tools for Visual Studio (PTVS)
281 | __pycache__/
282 | *.pyc
283 |
284 | # Cake - Uncomment if you are using it
285 | # tools/**
286 | # !tools/packages.config
287 |
288 | # Tabs Studio
289 | *.tss
290 |
291 | # Telerik's JustMock configuration file
292 | *.jmconfig
293 |
294 | # BizTalk build output
295 | *.btp.cs
296 | *.btm.cs
297 | *.odx.cs
298 | *.xsd.cs
--------------------------------------------------------------------------------