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.
No Comment
Post your comment