Bash snippet : Recursively delete node_modules, vendor, and .git folder from multiple laravel projects using .sh file

Usefull for recursively delete node_modules, vendor folders from multiple laravel projects, at once.

#!/bin/bash
# This is a recursive delete script for multiple laravel projects 
# @arguments:
#
# Deletes the folders inside the folder where this script.sh file is placed
# Example : If you have many laravel projects inside /var/www/, create script.sh with this contents and run from terminal, sudo bash script.sh
#
# @install: 
# $ chmod +x script.sh
# $ sudo bash script.sh
#
for D in ./*; do
    if [ -d "$D" ]; then
        cd "$D"
            for X in ./*; do
                if [ -d "$X" ]; then
                    #uncomment below line if you want to delete all .zip files in the projects root directory
                    #find . -name "*.zip" -type f | xargs rm -rf   
                    #uncomment below line if you want to delete .git folder in the projects root directory                                     
                    if [ "$X" == "./node_modules" ] || [ "$X" == "./vendor" ]; then 
                        echo "match found";
                        rm -rf "$X"
                        echo "match deleted";
                    else 
                        echo "not a match";
                    fi
                fi
            done
        cd ..
    fi
done
# script.sh;

Usage : create script.sh file in directory, where all projects are in. In terminal, run, sudo bash script.sh

Read Article →

Laravel homestead and vagrant-hostsupdater - Automate the hosts file updation in windows for your next homestead project!

Lets configure homestead.rb to update hosts file using hostsupdater plugin. in case if you have not yet added this plugin, run
vagrant plugin install vagrant-hostsupdater
from your command prompt.
Open homestead.rb file in your favorite text editor.
Find this block at the end, (You can set anywhere but i prefer to add my customizations at the end of the file.)

Read Article →

Drupal forgot password for admin - best method to reset with PHP file. (If you have FTP Access)

You have forgot your Drupal website's password! That's horrible. But dont worry, we have a better way to reset password if you have access to your files.

If you remember / have access to the admin email, its OK you can reset by going to forgot password page and by entering your email ID for admin account.

If not, you can try this method. I have combined snippets from around the web to make it work even if you have got blocked from login.


Read Article →

More Blog Posts →