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 livewire

Laravel livewire file upload demo

Livewire is a full-stack framework for the Laravel framework. It was the first time I wrote code, and he was probably the one who was able to write and marvel at the magic. My colleague also marveled while writing after being pushed by me. When I first learned Vue, I was not so surprised by him.

laravel,blade

New features in Laravel 5.5, in Blade's "json" directive

Laravel 5.5 supports a new directive called json. In the Blade template, json can be printed without calling json_encode.

dlaravel

How to directly execute the php artisan of different projects in the container on the host.

This article is the application teaching of D-Laravel, how to directly execute php artisan in the container on the host side. After customizing the alias, you can directly execute php artisan in the contianer in the project folder on the host side. alias a="../../artisan.sh"