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

Super easy to use HTML to PDF kit mpdf introduction

During development, will it be necessary to output HTML to PDF? This video introduces how to output PDF on the screen through the mpdf library of php.

laravel storage

How do I sync files with Laravel's Storage's sftp driver

The installation and setting of SFTP is beyond the scope of this article. If you want to know more, I suggest you read another article https://www.ccc.tc/article/Laravel-SFTP-Driver-Configuration. In this article, I will use a very fast Sample. Demo How do I use the self-built artisan command to synchronize the remote data to the local end. Some people may ask why rsync is not used. This article is to introduce the use of Storage to synchronize files. 🤪Let’s look directly at the code, I set up an sftp disk called ccc in config/filesystems.php.

dlaravel

D-Laravel's sublime plug-in can be installed by Package Control.

Mac or Linux users can now install the D-Laravel alias package from Sublime3's package control. Through D-Laravel alias, we can execute artisan and composer commands in the container in an easier way. In the docker environment, do you want to use composer to install the package? You don’t need to enter the container, or set the ce alias of composer, and you can execute it directly in sublime.