Twinfield CLI
twf is Twinfield on the command line. Log in once, then list your offices, send XML requests, or use the same login in your PHP tests, examples and scripts.
Installation
Section titled “Installation”Twinfield CLI is a Composer package. It needs PHP 8.3 or newer.
composer require --dev solvebeam/twinfield-cliComposer puts the command in vendor/bin/twf. vendor/bin/twinfield is the same command under its long name.
Log in
Section titled “Log in”vendor/bin/twf loginThis opens the Twinfield login in your browser and stores the login on your machine. You do not need a Twinfield client ID: by default the login goes through Twinfield Connect.
On a machine without a browser, for example over SSH, use twf login --manual.
Use it in the terminal
Section titled “Use it in the terminal”vendor/bin/twf statusvendor/bin/twf office listvendor/bin/twf process-xml request.xml --office=1000The manual has a page for each command.
Use it in PHP
Section titled “Use it in PHP”Credentials::default() gives the PHP Twinfield SDK the login of twf login. Your code does not need to know about OAuth.
use SolveBeam\Twinfield\Cli\Credentials;use SolveBeam\Twinfield\Twinfield;
$twinfield = Twinfield::create(Credentials::default());
foreach ($twinfield->offices()->list() as $office) { echo $office->code, ' ', $office->name, PHP_EOL;}It works like gcloud auth application-default login, aws sso login or gh auth login: the command line tool stores the login, and your code picks it up.
When to use it
Section titled “When to use it”- Tests and examples that call the live Twinfield API.
- Scripts you run yourself, such as an import or a report.
- CI, with environment variables instead of the login.
In an application where users log in themselves, use solvebeam/twinfield-connect or solvebeam/oauth2-twinfield and store the refresh tokens yourself.
Next steps
Section titled “Next steps”- Profiles: a login for each organisation.
- Scripting: output in a pipe, JSON and exit statuses.
- Where the login is stored.
Twinfield and Wolters Kluwer are trademarks of Wolters Kluwer. Their names and logos are used only to refer to their products.