Files
windmill/system_prompts/languages/php.md
centdix 31e002ad41 feat(ai): standardize and improve system prompts (#7346)
* init

* test in frontend

* copy files

* use in cli

* better

* add desc to sdks

* better

* fix ts parsing

* add docs to ts client

* add docs to python client

* use script prompt in frontend

* regen

* use in flow

* rm

* use in cli, create AGENTS.md instead of cursor rules

* remove apply

* better

* better

* simplify cli

* more docs

* cleaning

* update readme

* generate cli file

* better folder names

* fix ts

* fix multiline
2025-12-12 17:26:19 +00:00

58 lines
1.2 KiB
Markdown

# PHP
## Structure
The script must start with `<?php` and contain at least one function called `main`:
```php
<?php
function main(string $param1, int $param2) {
return ["result" => $param1, "count" => $param2];
}
```
## Resource Types
On Windmill, credentials and configuration are stored in resources and passed as parameters to main.
You need to **redefine** the type of the resources that are needed before the main function. Always check if the class already exists using `class_exists`:
```php
<?php
if (!class_exists('Postgresql')) {
class Postgresql {
public string $host;
public int $port;
public string $user;
public string $password;
public string $dbname;
}
}
function main(Postgresql $db) {
// $db contains the database connection details
}
```
The resource type name has to be exactly as specified.
## Library Dependencies
Specify library dependencies as comments before the main function:
```php
<?php
// require:
// guzzlehttp/guzzle
// stripe/stripe-php@^10.0
function main() {
// Libraries are available
}
```
One dependency per line. No need to require autoload, it is already done.