by Devin Yang
(This article was automatically translated.)

Published - 2 years ago ( Updated - 2 years ago )

The functions mentioned in this article can only be used for Laravel 8 and later versions
If we have some test websites outside Laravel with external IPs, but we only want to access them for ourselves.
This is how I do it for reference

First of all, I use zsh, so there is a gpw function in my ~/.zshrc, if you are using bash, it is ~/ .bashrc
So, when I need a simple random password, I can just execute gpw in the terminal and immediately spit out a random password to me.

  #generate password
  genpasswd() {
      date +%s | shasum | base64 | head -c 32 ; echo
  }
  alias gpw="genpasswd"


Then, I can build a pass.sh bash in the Laravel 8 or Laravel 9 project, the content is as follows:

#!/bin/bash
if [ $1 ];then
    php artisan up&&php artisan down --secret=$1
    PROJECT_URL=$(grep "APP_URL=" .env|cut -d= -f2)
    echo "$PROJECT_URL/$1"
else
    echo "Need new secret"
fi

Because it is a test site, I just want to see it for myself, so when I want to use it, I can set a new password for him at any time,
click the link to open it 😊


Why do you want to up and then down, because Laravel can't set new secret when it is in maintenance mode.
Of course, if you remember the password directly, you can write it down and add it to the bookmark.
 

Tags: laravel

Devin Yang

Feel free to ask me, if you don't get it.:)

No Comment

Post your comment

Login is required to leave comments

Similar Stories


laravel,Laravel security

Lock IP in Laravel debug mode

Laravel's debugging mode is quite rich. Laravel's official website has a reminder that you can set APP_DEBUG to true for local development, but in the production environment, this value must always be False.

laravel,woops

Laravel 5.5 Woops is back, let's check it out.

Woops is a framework for PHP error handling. It was preloaded in Laravel 4, but it was removed in Laravel 5.0, and now 5.5 is back.... Some features of Whoops include: - Flexible, stack-based error handling - No dependencies are required to use the current stand-alone library - Simple API for handling exceptions, tracking frames and their data -Include a stunning error page within your web application - Includes the ability to open referenced files directly in editors and IDEs - Includes handlers for different response formats (JSON, XML, SOAP) -Easy to extend and integrate with existing libraries - Clean, well structured and proven generation

dlaravel

D-laravel has added the recommended opcache.ini settings

The latest version of D-Laravel has added opcache's recommended settings. The enabling method is very simple, please execute it in the D-Laravel directory.