PHPackages                             humanmade/php-basic-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. humanmade/php-basic-auth

ActiveWordpress-muplugin[Authentication &amp; Authorization](/categories/authentication)

humanmade/php-basic-auth
========================

Basic PHP authentication for HM Dev and Staging environments.

1.1.7(4y ago)2197.7k—9.6%[2 issues](https://github.com/humanmade/PHPBasicAuth/issues)[1 PRs](https://github.com/humanmade/PHPBasicAuth/pulls)2GPL-3.0-or-laterPHPCI passing

Since Jan 7Pushed 3mo ago20 watchersCompare

[ Source](https://github.com/humanmade/PHPBasicAuth)[ Packagist](https://packagist.org/packages/humanmade/php-basic-auth)[ Docs](https://github.com/humanmade/PHPBasicAuth)[ RSS](/packages/humanmade-php-basic-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (4)Versions (12)Used By (2)

[![Human Made Logo](https://camo.githubusercontent.com/0563c4ffdc2d461425e0fa167430e989bdbe0b4ab14e87f1e001628d668ba68c/68747470733a2f2f68756d616e6d6164652e636f6d2f636f6e74656e742f7468656d65732f68756d616e6d6164652f6c69622f686d2d7061747465726e2d6c6962726172792f6173736574732f696d616765732f6c6f676f732f6c6f676f2d7265642e737667)](https://camo.githubusercontent.com/0563c4ffdc2d461425e0fa167430e989bdbe0b4ab14e87f1e001628d668ba68c/68747470733a2f2f68756d616e6d6164652e636f6d2f636f6e74656e742f7468656d65732f68756d616e6d6164652f6c69622f686d2d7061747465726e2d6c6962726172792f6173736574732f696d616765732f6c6f676f732f6c6f676f2d7265642e737667)

PHP Basic Auth
==============

[](#php-basic-auth)

[![GitHub release (latest by date)](https://camo.githubusercontent.com/d11c50475ff5ca7059883eed6f87d723656179c1b08f7017b2c7efe093eaf4f9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f68756d616e6d6164652f504850426173696341757468)](https://github.com/humanmade/PHPBasicAuth/releases) [![GitHub](https://camo.githubusercontent.com/7610afb2d69c444c7a4c48384388b0870b2000540d5890a3cad9b60a518825e7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f68756d616e6d6164652f504850426173696341757468)](https://github.com/humanmade/PHPBasicAuth/blob/master/LICENSE) [![Build Status](https://camo.githubusercontent.com/801de96d8fb45050d0962c28cb3b31585c5ef906e593cc1076c0617368651775/68747470733a2f2f7472617669732d63692e636f6d2f68756d616e6d6164652f5048504261736963417574682e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/humanmade/PHPBasicAuth)

Basic PHP authentication for Human Made Dev and Staging environments.

[![screenshot of prompt in google chrome](https://camo.githubusercontent.com/56f66f044e6f06dbf75226406ef91e0ffa0834329d63b9c63e08f06ff8750d74/68747470733a2f2f7039342e66332e6e302e63646e2e676574636c6f75646170702e636f6d2f6974656d732f4170756a4b4f64412f53637265656e73686f74253230323032302d30342d303825323030392e33302e34362e706e673f763d3061633564613936303039636137303435386534333362396265396130383937)](https://camo.githubusercontent.com/56f66f044e6f06dbf75226406ef91e0ffa0834329d63b9c63e08f06ff8750d74/68747470733a2f2f7039342e66332e6e302e63646e2e676574636c6f75646170702e636f6d2f6974656d732f4170756a4b4f64412f53637265656e73686f74253230323032302d30342d303825323030392e33302e34362e706e673f763d3061633564613936303039636137303435386534333362396265396130383937)Authentication prompt in Google Chrome

[![screenshot of prompt in firefox](https://camo.githubusercontent.com/f196ca86e263d97f4bf4707a2707cac50931e8231884788e6d098bd39e7b335e/68747470733a2f2f7039342e66332e6e302e63646e2e676574636c6f75646170702e636f6d2f6974656d732f59457531716445502f53637265656e73686f74253230323032302d30342d303825323030392e33302e31312e706e673f763d3531663961666566616635623236396563356661636264313035663936393238)](https://camo.githubusercontent.com/f196ca86e263d97f4bf4707a2707cac50931e8231884788e6d098bd39e7b335e/68747470733a2f2f7039342e66332e6e302e63646e2e676574636c6f75646170702e636f6d2f6974656d732f59457531716445502f53637265656e73686f74253230323032302d30342d303825323030392e33302e31312e706e673f763d3531663961666566616635623236396563356661636264313035663936393238)Authentication prompt in Firefox

Installation &amp; Setup
------------------------

[](#installation--setup)

The composer file is set up to assume you want to install this package with other WordPress must-use vendor plugins. These setup instructions assume that all your composer-required must-use plugins are stored in a main `/mu-plugins/vendor` directory and that you are using a `loader.php` file to require them. You may need to adjust the configuration if your environment is different.

After installation and setup, an option to override the default basic auth setting (detected by environment) will exist on the General settings page. This option allows you to disable the basic auth on dev or staging environments from the WordPress application. By default the option will detect the environment and be checked if no setting is saved.

[![screenshot of new setting](https://camo.githubusercontent.com/822801787b6da3579f8bbe8b11cb7105fbc0f592481233af061c17360bf27f00/68747470733a2f2f7039342e66332e6e302e63646e2e676574636c6f75646170702e636f6d2f6974656d732f50387559317871772f53637265656e73686f742b323032302d30312d30372b31352e35352e35302e706e673f763d3933303037383438626338323864613762643361613531323535336131663137)](https://camo.githubusercontent.com/822801787b6da3579f8bbe8b11cb7105fbc0f592481233af061c17360bf27f00/68747470733a2f2f7039342e66332e6e302e63646e2e676574636c6f75646170702e636f6d2f6974656d732f50387559317871772f53637265656e73686f742b323032302d30312d30372b31352e35352e35302e706e673f763d3933303037383438626338323864613762643361613531323535336131663137)

### Step 1

[](#step-1)

Install the plugin via `composer`.

```
composer require humanmade/php-basic-auth
```

### Step 2

[](#step-2)

Add `'vendor/php-basic-auth/plugin.php'` to the array of must-use plugins in the `loader.php` file in the root of your `/mu-plugins` directory. Make sure it is the *first* item in the array.

The final result should look something like this:

```
