You can install the package via Composer:
composer require studio24/staging-siteYou first need to create a staging site password and store this securely. You can generate this via PHP's password_hash function or by using the provided command line script:
php vendor/bin/password-hash.phpThis will generate a password hash, such as:
$2y$12$d.GZ1e/QVmM4SMJ4e9/42ehSyVV28.GTQKfqfd2P7WkLDYE519ElaNext choose your platform to install this on your website. In the examples below, replace the password hash string with your actual password hash.
TODO
If you want to customise the options, then you need a bit more code:
$controller = new \Studio24\StagingSitePassword\Controller($platform, $passwordHash);
if ($controller->isStaging()) {
$controller->authenticate();
}If you want to customise any options, you can do so via the controller object. Make sure you add your code before $controller->authenticate()
is run. For example:
$controller = new \Studio24\StagingSitePassword\Controller($platform);
$controller->loginPage->setPlaceholder('title', 'Login to My Website');
if ($controller->isStaging()) {
$controller->authenticate();
}You can customise any text on the login page via $controller->loginPage->setPlaceholder($name, $value).
Customise the title:
$controller->loginPage->setPlaceholder('title', 'Login to My Website');Customise the footer text (you can include HTML):
$controller->loginPage->setPlaceholder('footer', 'Get support from <a href="mailto:support@studio24.net">Studio 24</a>');The full list of placeholders:
| Placeholder name | Default value |
|---|---|
title |
Login to staging website |
footer |
|
password_field_label |
Password |
submit_field_label |
Login |
title_prefix_on_error |
Error: |
error_message_title |
There is a problem |
error_message |
The password is incorrect |
show |
Show |
hide |
Hide |
show_password |
Show password |
hide_password |
Hide password |
By default, the login cookie is set to expire after 7 days. You can customise this via:
$controller->auth->setCookieLifetime(3600); This sets the cookie lifetime in seconds.
You can also set this in days:
$controller->auth->setCookieLifetimeInDays(14); You can also change the cookie name (default is staging_site_remember_login):
$controller->auth->setCookieName('remember_me');