Created
September 11, 2020 14:22
-
-
Save flibidi67/7c2cfdc1ff1b977b48204be0bee5eb76 to your computer and use it in GitHub Desktop.
Script for handle two vendor directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MY_VENDOR_DIRECTORY=my-vendor | |
VENDOR_DIRECTORY=vendor | |
if [ ! -d "$MY_VENDOR_DIRECTORY" ] | |
then | |
echo "Le dossier $MY_VENDOR_DIRECTORY n'existe pas : on le crée." | |
mkdir $MY_VENDOR_DIRECTORY | |
else | |
echo "Le dossier $MY_VENDOR_DIRECTORY existe : on le vide." | |
rm -rf $MY_VENDOR_DIRECTORY/* | |
fi | |
echo "Copie des fichiers autoload généré depuis $VENDOR_DIRECTORY vers $MY_VENDOR_DIRECTORY." | |
cp $VENDOR_DIRECTORY/autoload.php $MY_VENDOR_DIRECTORY | |
cp -R $VENDOR_DIRECTORY/composer $MY_VENDOR_DIRECTORY | |
cd $MY_VENDOR_DIRECTORY/composer | |
echo "Remplacement de 'require \$file' par \str_replace(\"my-vendor\/composer\/..\", \"vendor\", \$file)" | |
sed -i 's/require $file/require \\str_replace("my-vendor\/composer\/..", "vendor", $file)/' autoload_real.php | |
echo "Remplacement de 'include \$file' par \str_replace(\"my-vendor\/composer\/..\", \"vendor\", \$file) " | |
sed -i 's/include $file/require \\str_replace("my-vendor\/composer\/..", "vendor", $file)/' ClassLoader.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script can be usefull when you want two Laravel projects to share the same vendor folder.
public/index.php
, replacerequire __DIR__.'/../vendor/autoload.php';
byrequire __DIR__.'/../my-vendor/autoload.php';
./my-vendor.sh
in yourcomposer.json
in thepost-autoload-dump
my-vendor
directory in your.gitignore
I only try this shellscript in the context of two laravel projects which shares the same vendor folder.