OOUI/PHP examples

There is a more extensive set of examples in the source code repository.

If you are using OOjs UI in a mediawiki extension, see ../Using_the_library_with_extensions.

If using the OOjs UI library in a standalone PHP project, run.

You may also wish to clone the repo and/or install it using composer, then take a look at. This provides concrete examples of using most of the widgets from PHP code.

Creating a button
To create a button, use the  class. The first and only argument to a button's constructor is its configuration.

Before the button is converted to HTML and emitted, the label, target and href can be changed using the  and   methods.

The button is now created, and has a label which reads "Still click me!", but is not yet visible to the user, as it must first converted to HTML and echoed into the document: