sh 该程序自动为基于Laravel框架的应用程序的公开发布创建一个干净的存档。为了安全起见,您需要ap

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 该程序自动为基于Laravel框架的应用程序的公开发布创建一个干净的存档。为了安全起见,您需要ap相关的知识,希望对你有一定的参考价值。

#!/bin/bash
#File:  zip.bash
#Author:John Muchiri
#Date:  10-Aug-2017
#
#This program automates creating a clean archive for public release of
#Laravel framework based application. For security, you will need to append .env-example to your final zip archive.
#For Windows with Ubuntu sub-system, create a .bat file called deploy.bat and append ./laravel-deploy.bash. 
#Then you can click on the .bat to run deployment script.
#
# The format of the final filename is myfile-mm-dd-YYYY-v1.zip. "v1" increments to v2 and so forth in consequent runs.
#

#Target filename
name="myfile"

#Target directory with no trailing slash!
target="/home/my-directory"

echo $(php artisan view:clear)
echo $(php artisan config:clear)
echo $(php artisan route:clear)
echo $(php artisan clear-compiled)
echo $(php artisan cache:clear)
echo $(composer dump-autoload)

echo "Testing target directory..."
path="$target/$name/"

if [ -d "$path" ]
then
    echo "Found target directory!"
else
    echo "Creating target directory"
    mkdir -p "$path"
fi

echo Reading current versions
ls "$path"

#read -p "Would you like to include Laravel assets? " -n 1 -r
# echo
# if [[ $REPLY =~ ^[Yy]$ ]]
# then
#     assets=""
# else
#     #exclude if no add "$assets$ after -x on zip command below
#     assets="resources/assets/"
# fi

fileName=$(find "$path" -type f -name "$name-*.zip")
IFS='-'
array=( $fileName )
currentVer="${array[4]//[^0-9]/}"
echo "Echo current versions is: $currentVer"

newVer="$(($currentVer+1))"
echo "Echo new version is: $newVer"

find storage/framework/sessions ! -name '.gitignore' -type f -exec rm {} +
rm -rf storage/debugbar
rm -df public/storage
rm -rf bash.exe.stackdump npm-debug.log storage/logs/laravel.log composer.lock

touch storage/logs/laravel.log

now=$(date +"%m-%d-%Y")

zip -r "$path$name-$now-v$newVer.zip" * -x "*.git*" "*.idea*" "*node_modules/*" "*vendor/*" "zip.bash" "deploy.bat" "npm-debug.log" ".env"

以上是关于sh 该程序自动为基于Laravel框架的应用程序的公开发布创建一个干净的存档。为了安全起见,您需要ap的主要内容,如果未能解决你的问题,请参考以下文章

laravel框架用啥语言

基于Laravel+Layui的小程序后台管理系统

自动生成CC++shell程序基本框架脚本

基于Laravel9+Layui的小程序后台管理系统

Vscode下调试基于Homestead环境的Laravel框架

17.)PHPWeb开发框架~Laravel中CSRF攻击原理讲解