by Devin Yang
(This article was automatically translated.)

Published - 1 year ago ( Updated - 1 year 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


dlaravel

D-Laravel test domain name *.dev changed to *.test

Since Google Chrome 63 will forcibly convert the domain name of *.dev to https, the domain name of the new version of D-Laravel will be changed to *.test. This article explains how to update.

laravel docker

About D-Laravel's project mode

If you are a new user, I suggest you use my latest environment phpenv instead. https://github.com/DevinY/phpenv

laravel teaching, blade

Tags on my Laravel blade

Using Laravel's Blade Templates is quite easy to use, and I'm used to it after a long time, but one thing is that when a lot of blades are created, it seems that it is not easy to find myself. Here is my latest original method. If it is the same Pure coincidence.