CINXE.COM

design/codex-php - Gitiles

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>design/codex-php - Gitiles</title><link rel="stylesheet" type="text/css" href="/r/plugins/gitiles/+static/base.css"><link rel="stylesheet" type="text/css" href="/r/plugins/gitiles/+static/doc.css"><!-- default customHeadTagPart --></head><body class="Site"><header class="Site-header"><div class="Header"><!-- default customHeader --><div class="Header-title">Gitiles</div><div class="Header-menu"> <a class="Header-menuItem" href="https://gerrit.wikimedia.org/r/">Code Review</a> <a class="Header-menuItem" href="https://gerrit.wikimedia.org/r/login/plugins%2Fgitiles%2Fdesign%2Fcodex-php">Sign In</a> </div></div></header><div class="Site-content"><div class="Container "><div class="Breadcrumbs"><a class="Breadcrumbs-crumb" href="/r/plugins/gitiles/?format=HTML">gerrit.wikimedia.org</a> / <a class="Breadcrumbs-crumb" href="/r/plugins/gitiles/design/">design</a> / <span class="Breadcrumbs-crumb">codex-php</span></div><h2 class="RepoDescription">test</h2><div class="CloneRepo"><div class="CloneRepo-title">Clone this repo:</div><input id="clone-repo-input" type="text" class="u-monospace CloneRepo-command" readonly="readonly" value="git clone https://gerrit.wikimedia.org/r/design/codex-php"></div><div class="RepoShortlog"><div class="RepoShortlog-refs"><div class="RefList RefList--responsive"><h3 class="RefList-title">Branches</h3><ul class="RefList-items"><li class="RefList-item"><a href="/r/plugins/gitiles/design/codex-php/+/refs/heads/main">main</a></li></ul></div><div class="RefList RefList--responsive"><h3 class="RefList-title">Tags</h3><ul class="RefList-items"><li class="RefList-item"><a href="/r/plugins/gitiles/design/codex-php/+/refs/tags/v0.3.0">v0.3.0</a></li><li class="RefList-item"><a href="/r/plugins/gitiles/design/codex-php/+/refs/tags/v0.2.0">v0.2.0</a></li><li class="RefList-item"><a href="/r/plugins/gitiles/design/codex-php/+/refs/tags/v0.1.0">v0.1.0</a></li></ul></div></div><div class="RepoShortlog-log"><ol class="CommitLog"><li class="CommitLog-item CommitLog-item--oneline"><a class="u-sha1 u-monospace CommitLog-sha1" href="/r/plugins/gitiles/design/codex-php/+/0fae5c51f7c320fa0cb3314a5e69b17c094240fe">0fae5c5</a> <a href="/r/plugins/gitiles/design/codex-php/+/0fae5c51f7c320fa0cb3314a5e69b17c094240fe">Tag: v0.3.0</a> <span class="CommitLog-author" title="gardner.ec@gmail.com">by Eric Gardner</span> <span class="CommitLog-time" title="Mon Dec 16 16:20:41 2024 -0500">路 31 hours ago</span> <a class="CommitLog-branchLabel" href="/r/plugins/gitiles/design/codex-php/+/refs/heads/main">main</a> <a class="CommitLog-tagLabel" href="/r/plugins/gitiles/design/codex-php/+/refs/tags/v0.3.0">v0.3.0</a></li><li class="CommitLog-item CommitLog-item--oneline"><a class="u-sha1 u-monospace CommitLog-sha1" href="/r/plugins/gitiles/design/codex-php/+/1e94228c9c095e3674e42837b45ef86476c50398">1e94228</a> <a href="/r/plugins/gitiles/design/codex-php/+/1e94228c9c095e3674e42837b45ef86476c50398">tests: Use class-level @covers annotations instead @coversDefaultClass</a> <span class="CommitLog-author" title="abaris@null.net">by Do臒u Abaris</span> <span class="CommitLog-time" title="Sat Dec 14 19:37:00 2024 +0100">路 3 days ago</span></li><li class="CommitLog-item CommitLog-item--oneline"><a class="u-sha1 u-monospace CommitLog-sha1" href="/r/plugins/gitiles/design/codex-php/+/edab57b89d1a8ce1e9fbea413e23ceeef9480b1a">edab57b</a> <a href="/r/plugins/gitiles/design/codex-php/+/edab57b89d1a8ce1e9fbea413e23ceeef9480b1a">Merge &quot;Add .gitmessage template for standardized commit messages&quot; into main</a> <span class="CommitLog-author" title="jenkins-bot@gerrit.wikimedia.org">by jenkins-bot</span> <span class="CommitLog-time" title="Mon Dec 16 21:03:13 2024 +0000">路 32 hours ago</span></li><li class="CommitLog-item CommitLog-item--oneline"><a class="u-sha1 u-monospace CommitLog-sha1" href="/r/plugins/gitiles/design/codex-php/+/68cd5648d88349df1719b43afc3f1496c3c27419">68cd564</a> <a href="/r/plugins/gitiles/design/codex-php/+/68cd5648d88349df1719b43afc3f1496c3c27419">Merge &quot;ThumbnailRenderer: Fix null handling for backgroundImage and placeholder&quot; into main</a> <span class="CommitLog-author" title="jenkins-bot@gerrit.wikimedia.org">by jenkins-bot</span> <span class="CommitLog-time" title="Mon Dec 16 21:02:26 2024 +0000">路 32 hours ago</span></li><li class="CommitLog-item CommitLog-item--oneline"><a class="u-sha1 u-monospace CommitLog-sha1" href="/r/plugins/gitiles/design/codex-php/+/93a02df7ce88789e74df955689dcb0ab4c0452ed">93a02df</a> <a href="/r/plugins/gitiles/design/codex-php/+/93a02df7ce88789e74df955689dcb0ab4c0452ed">Add .gitmessage template for standardized commit messages</a> <span class="CommitLog-author" title="abaris@null.net">by Do臒u Abaris</span> <span class="CommitLog-time" title="Sat Dec 14 18:58:52 2024 +0100">路 3 days ago</span></li></ol><nav class="LogNav"><a class="LogNav-next" href="/r/plugins/gitiles/design/codex-php/+log">More &raquo;</a></nav><div class="doc RepoIndexDoc"><h1><a class="h" name="Wikimedia-Codex" href="#Wikimedia-Codex"><span></span></a><a class="h" name="wikimedia-codex" href="#wikimedia-codex"><span></span></a>Wikimedia Codex</h1><p>A PHP library for building HTML and CSS UI components using <a href="https://doc.wikimedia.org/codex/main/">Codex</a>, the Wikimedia design system.</p><p><a href="https://packagist.org/packages/wikimedia/codex"><img src="http://poser.pugx.org/wikimedia/codex/v?style=for-the-badge" alt="Latest Stable Version" /></a> <a href="https://packagist.org/packages/wikimedia/codex"><img src="http://poser.pugx.org/wikimedia/codex/v/unstable?style=for-the-badge" alt="Latest Unstable Version" /></a> <a href="https://packagist.org/packages/wikimedia/codex"><img src="http://poser.pugx.org/wikimedia/codex/license?style=for-the-badge" alt="License" /></a> <a href="https://packagist.org/packages/wikimedia/codex"><img src="http://poser.pugx.org/wikimedia/codex/require/php?style=for-the-badge" alt="PHP Version Require" /></a></p><h2><a class="h" name="Installation" href="#Installation"><span></span></a><a class="h" name="installation" href="#installation"><span></span></a>Installation</h2><p>Use Composer to install the Codex library:</p><pre class="code"><span class="pln">composer require wikimedia</span><span class="pun">/</span><span class="pln">codex </span></pre><h2><a class="h" name="Components" href="#Components"><span></span></a><a class="h" name="components" href="#components"><span></span></a>Components</h2><p>The Codex library provides a variety of components to build UI:</p><ul><li><strong>Accordion</strong>: A collapsible and expandable section for organizing content.</li><li><strong>Button</strong>: A clickable button that can be styled to reflect different actions.</li><li><strong>Card</strong>: A component for grouping information and actions related to a single topic.</li><li><strong>Checkbox</strong>: A form element that allows users to select one or more options.</li><li><strong>Field</strong>: A container for grouping form elements with optional legend and help a text.</li><li><strong>InfoChip</strong>: A small component used to display brief information or tags.</li><li><strong>Label</strong>: A component used to label other form elements.</li><li><strong>Message</strong>: A component to display information, warnings, or errors to users.</li><li><strong>Pager</strong>: A component for navigating through pages of data.</li><li><strong>ProgressBar</strong>: A visual indicator of progress toward a goal or task completion.</li><li><strong>Radio</strong>: A form element that allows users to select one option from a set.</li><li><strong>Select</strong>: A dropdown component that allows users to select an option from a list.</li><li><strong>Table</strong>: A component for arranging data in rows and columns.</li><li><strong>Tabs</strong>: A component that organizes content into multiple panels with selectable tabs.</li><li><strong>TextArea</strong>: A multi-line text input field for user input.</li><li><strong>TextInput</strong>: A single-line text input field for user input.</li><li><strong>Thumbnail</strong>: A visual component for displaying small preview images.</li><li><strong>ToggleSwitch</strong>: A ToggleSwitch enables the user to instantly toggle between on and off states.</li></ul><h2><a class="h" name="Usage" href="#Usage"><span></span></a><a class="h" name="usage" href="#usage"><span></span></a>Usage</h2><p>Here is a basic example of how to use the Codex library:</p><pre class="code"><span class="pun">&lt;?</span><span class="pln">php </span><span class="kwd">require</span><span class="pln"> </span><span class="str">&#39;vendor/autoload.php&#39;</span><span class="pun">;</span><span class="pln"> </span><span class="kwd">use</span><span class="pln"> </span><span class="typ">Wikimedia</span><span class="pln">\Codex\Utility\Codex $codex </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Codex</span><span class="pun">();</span><span class="pln"> $accordion </span><span class="pun">=</span><span class="pln"> $codex </span><span class="pun">-&gt;</span><span class="pln">accordion</span><span class="pun">()</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">setTitle</span><span class="pun">(</span><span class="pln"> </span><span class="str">&quot;Accordion Example&quot;</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">setDescription</span><span class="pun">(</span><span class="pln"> </span><span class="str">&quot;This is an example of an accordion.&quot;</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">setContentHtml</span><span class="pun">(</span><span class="pln"> $codex </span><span class="pun">-&gt;</span><span class="pln">htmlSnippet</span><span class="pun">()</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">setContent</span><span class="pun">(</span><span class="pln"> </span><span class="str">&quot;&lt;p&gt;This is the content.&lt;/p&gt;&quot;</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">build</span><span class="pun">()</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">setOpen</span><span class="pun">(</span><span class="pln"> </span><span class="kwd">false</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">setAttributes</span><span class="pun">(</span><span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="str">&quot;class&quot;</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="str">&quot;foo&quot;</span><span class="pun">,</span><span class="pln"> </span><span class="str">&quot;bar&quot;</span><span class="pln"> </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="str">&quot;baz&quot;</span><span class="pun">,</span><span class="pln"> </span><span class="pun">]</span><span class="pln"> </span><span class="pun">)</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">build</span><span class="pun">()</span><span class="pln"> </span><span class="pun">-&gt;</span><span class="pln">getHtml</span><span class="pun">();</span><span class="pln"> echo $accordion</span><span class="pun">;</span><span class="pln"> </span><span class="pun">?&gt;</span><span class="pln"> </span></pre><h2><a class="h" name="Scripts" href="#Scripts"><span></span></a><a class="h" name="scripts" href="#scripts"><span></span></a>Scripts</h2><p>The following scripts are defined for testing and code fixing purposes:</p><ul><li><code class="code">test</code>: Run linting and code checks.</li><li><code class="code">fix</code>: Automatically fix code style issues.</li><li><code class="code">phan</code>: Run the Phan static analyzer.</li><li><code class="code">phpcs</code>: Run the PHP Code Sniffer.</li><li><code class="code">start-sandbox</code>: Start the sandbox environment for testing.</li></ul><p>Example usage:</p><pre class="code"><span class="pln">composer run</span><span class="pun">-</span><span class="pln">script test composer run</span><span class="pun">-</span><span class="pln">script fix composer run</span><span class="pun">-</span><span class="pln">script phan composer run</span><span class="pun">-</span><span class="pln">script phpcs composer run</span><span class="pun">-</span><span class="pln">script start</span><span class="pun">-</span><span class="pln">sandbox </span></pre><h2><a class="h" name="License" href="#License"><span></span></a><a class="h" name="license" href="#license"><span></span></a>License</h2><p>This project is licensed under the GPL-2.0-or-later. See the <a href="codex-php/+/HEAD/LICENSE">LICENSE</a> file for details.</p><h2><a class="h" name="Contributing" href="#Contributing"><span></span></a><a class="h" name="contributing" href="#contributing"><span></span></a>Contributing</h2><p>Please read the <a href="codex-php/+/HEAD/CONTRIBUTING.md">CONTRIBUTING</a> file for details on our code of conduct, and the process for submitting pull requests to us.</p><h2><a class="h" name="Bugs" href="#Bugs"><span></span></a><a class="h" name="bugs" href="#bugs"><span></span></a>Bugs</h2><p>Report bugs at <a href="https://phabricator.wikimedia.org/tag/codex/">Phabricator</a>.</p><h2><a class="h" name="Homepage" href="#Homepage"><span></span></a><a class="h" name="homepage" href="#homepage"><span></span></a>Homepage</h2><p>For more information, visit the <a href="https://doc.wikimedia.org/codex/">homepage</a>.</p></div></div></div></div> <!-- Container --></div> <!-- Site-content --><!-- default customFooter --><footer class="Site-footer"><div class="Footer"><span class="Footer-poweredBy">Powered by <a href="https://gerrit.googlesource.com/gitiles/">Gitiles</a></span><span class="Footer-formats"><a class="u-monospace Footer-formatsItem" href="?format=TEXT">txt</a> <a class="u-monospace Footer-formatsItem" href="?format=JSON">json</a></span></div></footer></body></html><script>{let f = document.getElementById("clone-repo-input"); f.onclick = () => {f.focus(); if (f.selectionStart === f.selectionEnd) {f.select();}};}</script>

Pages: 1 2 3 4 5 6 7 8 9 10