Files
openidea/generators/php.toml
T
l0ng-ai 605d5f4985 feat(new-project): project generators for mainstream languages and frameworks (#2689)
File › New Project offers 38 generators grouped by language (Java, Spring Boot, Quarkus, Micronaut, Kotlin, Ktor, Scala, Python/Django/FastAPI/Flask, Node/Vite/Next.js/Nuxt/Angular/SvelteKit/Astro/NestJS/Express, Go, Rust, C/C++, Zig, .NET, PHP/Laravel/Symfony, Ruby/Rails, Dart/Flutter, Swift, Elixir/Phoenix, Haskell, static website, empty). Each is a declaration in generators/<id>.toml run by the new ide-scaffold crate: built-in templates, the framework's official CLI run non-interactively, or a project service zip (Spring Initializr, code.quarkus.io, Micronaut Launch) whose metadata becomes form fields. Projects are built in a staging directory and moved into place only on success. The dialog renders each form from its schema, flags missing toolchains with install hints and streams progress; created projects open trusted. New Project is also on the welcome screen and the title bar project menu.

Closes #709
2026-11-11 17:22:57 +08:00

87 lines
1.4 KiB
TOML

id = "php"
name = "PHP"
group = "PHP"
icon = "project-php"
description = "A Composer project with PSR-4 autoloading."
[[requires]]
program = "php"
min = "8.2"
hint = "Install PHP 8.2 or later: https://www.php.net/downloads"
[[requires]]
program = "composer"
hint = "Install Composer: https://getcomposer.org/download/"
[[fields]]
id = "vendor"
label = "Vendor:"
type = "text"
pattern = '^[a-z0-9]([_.-]?[a-z0-9]+)*$'
default = "acme"
[[fields]]
id = "namespace"
label = "Namespace:"
type = "text"
pattern = '^[A-Za-z_][A-Za-z0-9_]*(\\[A-Za-z_][A-Za-z0-9_]*)*$'
default = "{{vendor|pascal}}\\{{name|pascal}}"
[[files]]
path = "composer.json"
content = '''
{
"name": "{{vendor}}/{{name|kebab}}",
"type": "project",
"require": {
"php": ">=8.2"
},
"autoload": {
"psr-4": {
"{{namespace|json}}\\": "src/"
}
}
}
'''
[[files]]
path = "src/App.php"
content = '''
<?php
declare(strict_types=1);
namespace {{namespace}};
final class App
{
public function greet(string $name): string
{
return "Hello, {$name}!";
}
}
'''
[[files]]
path = "public/index.php"
content = '''
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
echo (new \{{namespace}}\App())->greet('World'), PHP_EOL;
'''
[[files]]
path = ".gitignore"
content = '''
vendor/
'''
[[after]]
label = "Generating the autoloader"
program = "composer"
args = ["dump-autoload", "--no-interaction"]