Jump to content

Local development quickstart: Difference between revisions

From mediawiki.org
Content deleted Content added
Kxeon (talk | contribs)
No edit summary
m Remove extra spaces
 
(32 intermediate revisions by 17 users not shown)
Line 1: Line 1:
<languages/>
<languages/>
{{InstallationNav}}
<translate><!--T:1--> This page is a '''quickstart''' guide to setting up a local development for MediaWiki using PHP and Composer.</translate>
<translate><!--T:1--> This page is a '''quickstart''' guide to setting up a local development for MediaWiki using PHP and Composer.</translate>


Line 6: Line 7:
<translate>
<translate>
== Install prerequisites == <!--T:28-->
== Install prerequisites == <!--T:28-->

<!--T:4-->
MediaWiki requires PHP 7.4.3+ and Composer 2.
</translate>
</translate>
<translate><!--T:40--> MediaWiki's master branch requires {{<tvar name=1>ll|Compatibility#PHP</tvar>|PHP 8.3.0+}} and Composer 2.</translate>
{{void|1=<translate><!--T:4--> MediaWiki requires PHP <tvar name=1>{{MW stable php requirement}}</tvar>+ and Composer 2.</translate>}}


{{TabbedWindowBegin}}
{{TabbedWindowBegin}}
Line 17: Line 17:
<translate>
<translate>
<!--T:5-->
<!--T:5-->
On Ubuntu 22+ or Debian 11+, install the required packages using [[w:APT (software)|APT]].
On Ubuntu <tvar name=1>24</tvar>+ or Debian <tvar name=2>13</tvar>+, install the required packages using [[w:APT (software)|APT]].
</translate>
</translate>


<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
sudo apt install -y php php-intl php-mbstring php-xml php-apcu php-curl php-sqlite3 composer
sudo apt install php php-intl php-mbstring php-xml php-apcu php-curl php-sqlite3 composer
</syntaxhighlight>
</syntaxhighlight>


<translate><!--T:6--> On Ubuntu 20, install PHP from APT, but install Composer from <tvar name=1>[https://getcomposer.org/download/ getcomposer.org/download]</tvar>.</translate>
<translate><!--T:7--> On Fedora <tvar name=1>40</tvar>+, install the required packages using [[w:DNF (software)|DNF]].</translate>


<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
sudo apt install -y php php-intl php-mbstring php-xml php-apcu php-curl php-sqlite3
sudo dnf install php composer
</syntaxhighlight>

<translate><!--T:7--> On Fedora 35+, install the required packages using [[w:DNF (software)|DNF]].</translate>

<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
sudo dnf install -y php composer
</syntaxhighlight>
</syntaxhighlight>


Line 39: Line 33:


<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
sudo pacman -S php composer --noconfirm
sudo pacman -S php composer
</syntaxhighlight>
</syntaxhighlight>


=== Mac ===
=== Mac ===

<translate>
<translate>
<!--T:9-->
<!--T:9-->
Install the required packages using [<tvar name=url>https://brew.sh/</tvar> Homebrew].
Install the required packages using [<tvar name=url>https://brew.sh/</tvar> Homebrew] and make it the active version of PHP, by linking it.
</translate>
</translate>


<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
brew install php@8.2 composer
brew install php@8.5 composer
brew link php@8.2
brew link --overwrite php@8.5
</syntaxhighlight>
</syntaxhighlight>


<translate><!--T:38--> If the following command succeeds, it should show the PHP version.</translate>
=== Windows ===
<translate><!--T:39--> If it fails, likely your <tvar name=1>$PATH</tvar> is not configured to find commands from brew.</translate>


<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
php -v
</syntaxhighlight>

=== Windows ===
<translate><!--T:10--> You have the option to use the [<tvar name=url>https://learn.microsoft.com/en-us/windows/wsl/about</tvar> Windows Subsystem for Linux] and follow the Linux instructions on this page.</translate>
<translate><!--T:10--> You have the option to use the [<tvar name=url>https://learn.microsoft.com/en-us/windows/wsl/about</tvar> Windows Subsystem for Linux] and follow the Linux instructions on this page.</translate>
<translate><!--T:11--> Or, to install MediaWiki directly on Windows, install the required packages using [<tvar name=url>https://chocolatey.org/install</tvar> Chocolatey].</translate>
<translate><!--T:11--> Or, to install MediaWiki directly on Windows, install the required packages using [<tvar name=url>https://chocolatey.org/install</tvar> Chocolatey].</translate>
Line 67: Line 66:


<syntaxhighlight lang="ini">
<syntaxhighlight lang="ini">
extension:fileinfo
extension=fileinfo
extension:intl
extension=intl
extension:pdo_sqlite
extension=pdo_sqlite
extension:zip
extension=zip
extension=sodium
</syntaxhighlight>
</syntaxhighlight>


Line 76: Line 76:


<translate>
<translate>

== Clone MediaWiki == <!--T:29-->
== Clone MediaWiki == <!--T:29-->


Line 84: Line 83:


<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
git clone https://gerrit.wikimedia.org/r/mediawiki/core.git mediawiki
git clone https://gerrit.wikimedia.org/r/mediawiki/core.git mediawiki
</syntaxhighlight>
<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
git clone https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git mediawiki/skins/Vector
git clone https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git mediawiki/skins/Vector
</syntaxhighlight>
<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
cd mediawiki
cd mediawiki
</syntaxhighlight>
</syntaxhighlight>


<translate><!--T:15--> Cloning MediaWiki takes a few minutes.</translate>
<translate><!--T:15--> Cloning MediaWiki takes a few minutes.</translate>
<translate><!--T:16--> While you're waiting, {{<tvar name=1>ll|Developer account</tvar>|create a Wikimedia developer account}} if you don't already have one.</translate>
<translate><!--T:16--> While you're waiting, if you plan to create and share patches, {{<tvar name=1>ll|Developer account</tvar>|create a Wikimedia developer account}} if you don't already have one.</translate>


<translate>
<translate>
Line 125: Line 128:


<translate>
<translate>
== Block of commands for MediaWiki installation == <!--T:19-->
== Next steps == <!--T:19-->
</translate>
<syntaxhighlight lang="bash" copy style="max-width: fit-content;">
git clone https://gerrit.wikimedia.org/r/mediawiki/core.git mediawiki
git clone https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git mediawiki/skins/Vector
cd mediawiki
composer update
composer serve
</syntaxhighlight>

<translate>

== Next steps == <!--T:20-->
</translate>
</translate>
* {{ll|Manual:Code|Take a tour of the MediaWiki codebase}} – <translate><!--T:21--> Familiarize yourself with MediaWiki's core code by learning about entry points and top-level directories.</translate>
* {{ll|Manual:Code|2=<translate><!--T:33--> Take a tour of the MediaWiki codebase</translate>}} – <translate><!--T:21--> Familiarize yourself with MediaWiki's core code by learning about entry points and top-level directories.</translate>
* {{ll|Manual:PHP unit testing|Run unit tests}} – <translate><!--T:22--> MediaWiki uses the PHPUnit framework for unit and integration testing of PHP code. Read the docs to run tests and find information about writing tests.</translate>
* {{ll|Manual:PHP unit testing|2=<translate><!--T:34--> Run unit tests</translate>}} – <translate><!--T:22--> MediaWiki uses the PHPUnit framework for unit and integration testing of PHP code. Read the docs to run tests and find information about writing tests.</translate>
* {{ll|Manual:Extensions|Install extensions}} – <translate><!--T:25--> Add extensions, like {{<tvar name=1>ll|Extension:VisualEditor</tvar>|VisualEditor}} and <tvar name=2>{{ll|Extension:Echo|Echo}}</tvar>, to your development environment.</translate> <translate><!--T:26--> See <tvar name=1>{{ll|Manual:Developing extensions}}</tvar> to learn about how extensions work.</translate>
* {{ll|Manual:Extensions|2=<translate><!--T:35--> Install extensions</translate>}} – <translate><!--T:25--> Add extensions, like {{<tvar name=1>ll|Extension:VisualEditor</tvar>|VisualEditor}} and <tvar name=2>{{ll|Extension:Echo|Echo}}</tvar>, to your development environment.</translate> <translate><!--T:26--> See <tvar name=1>{{ll|Manual:Developing extensions}}</tvar> to learn about how extensions work.</translate>
* {{ll|Manual:How to debug|Debug your code}} – <translate><!--T:23--> Learn how to configure debugging aids, and debug MediaWiki code step-by-step with XDebug.</translate>
* {{ll|Manual:How to debug|2=<translate><!--T:36--> Debug your code</translate>}} – <translate><!--T:23--> Learn how to configure debugging aids, and debug MediaWiki code step-by-step with XDebug.</translate>
* {{ll|Gerrit/Tutorial|Submit a patch}} – <translate><!--T:27--> Explore <tvar name=1>{{ll|good first bugs}}</tvar>, and {{<tvar name=2>ll|Gerrit/Tutorial#Configure Git</tvar>|configure SSH access}} to Wikimedia Gerrit to submit a patch.</translate>
* {{ll|Gerrit/Tutorial|2=<translate><!--T:37--> Submit a patch</translate>}} – <translate><!--T:27--> Explore <tvar name=1>{{ll|good first bugs}}</tvar>, and {{<tvar name=2>ll|Gerrit/Tutorial#Configure Git</tvar>|configure SSH access}} to Wikimedia Gerrit to submit a patch.</translate>


[[Category:Development environments{{#translation:}}]]
[[Category:Development environments{{#translation:}}]]

Latest revision as of 19:32, 28 July 2026



This page is a quickstart guide to setting up a local development for MediaWiki using PHP and Composer.

This workflow is only suitable for local development. To serve a public website, see Manual:Installation requirements .

Install prerequisites

MediaWiki's master branch requires PHP 8.3.0+ and Composer 2.

Linux

On Ubuntu 24+ or Debian 13+, install the required packages using APT.

sudo apt install php php-intl php-mbstring php-xml php-apcu php-curl php-sqlite3 composer

On Fedora 40+, install the required packages using DNF.

sudo dnf install php composer

On Arch Linux, install the required packages using pacman.

sudo pacman -S php composer

Mac

Install the required packages using Homebrew and make it the active version of PHP, by linking it.

brew install php@8.5 composer
brew link --overwrite php@8.5

If the following command succeeds, it should show the PHP version. If it fails, likely your $PATH is not configured to find commands from brew.

php -v

Windows

You have the option to use the Windows Subsystem for Linux and follow the Linux instructions on this page. Or, to install MediaWiki directly on Windows, install the required packages using Chocolatey.

choco install -y php composer

To load the required PHP extensions, edit your php.ini file, and uncomment the following lines. To find the location of php.ini, run php --ini, and look for Loaded Configuration File.

extension=fileinfo
extension=intl
extension=pdo_sqlite
extension=zip
extension=sodium

Clone MediaWiki

Use Git to clone the MediaWiki core repository and the default skin.

git clone https://gerrit.wikimedia.org/r/mediawiki/core.git mediawiki
git clone https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git mediawiki/skins/Vector
cd mediawiki

Cloning MediaWiki takes a few minutes. While you're waiting, if you plan to create and share patches, create a Wikimedia developer account if you don't already have one.

Install dependencies

From within your mediawiki directory, created above, use Composer to install MediaWiki's dependencies.

composer update

Install MediaWiki

Install MediaWiki with PHP's built-in SQLite database.

composer mw-install:sqlite

Start server

Start PHP's built-in webserver, and open localhost:4000 in a browser to see your MediaWiki instance. To log in as an administrator , use username Admin and password adminpassword.

composer serve

Next steps