windmill-labs / write-script-php
Install for your project team
Run this command in your project directory to install the skill for your entire team:
mkdir -p .claude/skills/write-script-php && curl -L -o skill.zip "https://fastmcp.me/Skills/Download/3453" && unzip -o skill.zip -d .claude/skills/write-script-php && rm skill.zip
Project Skills
This skill will be saved in .claude/skills/write-script-php/ and checked into git. All team members will have access to it automatically.
Important: Please verify the skill by reviewing its instructions before using it.
MUST use when writing PHP scripts.
0 views
0 installs
Skill Content
---
name: write-script-php
description: MUST use when writing PHP scripts.
---
## CLI Commands
Place scripts in a folder. After writing, tell the user they can run:
- `wmill script generate-metadata` - Generate .script.yaml and .lock files
- `wmill sync push` - Deploy to Windmill
Do NOT run these commands yourself. Instead, inform the user that they should run them.
Use `wmill resource-type list --schema` to discover available resource types.
# 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.