Categories
Fixing Stuff Mac Samuel

Updating Mac Hosts File

  1. open iTerm and type sudo nano /etc/hosts
  2. enter in password
  3. Type in the TCP/IP address
  4. Press the Tab key
  5. Type the domain name
  6. Save the file by pressing Ctrl + O (zero)
  7. Exit with Ctrl + X

— Update —

Just add this to your .aliases file so you can open up terminal and type hosts like our buddy Jeffry 🙂

alias hosts=”sudo nano /etc/hosts”

Categories
Fixing Stuff Mac Samuel

Getting Local ENV Setup To Run Old Site

First issue:

Library not loaded: /usr/local/opt/openldap/lib/libldap-2.5.0.dylib
  Referenced from: /usr/local/Cellar/php@7.3/7.3.33/bin/php

To fix this we ran:

Just do this:

brew tap shivammathur/php
brew link --overwrite --force php

done....
brew unlink php@8.1
brew link php@7.4 
brew services restart --all
composer global update
valet use php@7.4
    *this should confirm that valet is set to use php 7.4

***If we want to go farther back and use PHP7.3 or older, we have to do the following:

brew tap shivammathur/php
brew install shivammathur/php/php@7.3
brew unlink php@7.4
brew link php@7.3  
brew services restart --all
composer global update
valet use php@7.3  
     *this should confirm that valet is set to use php 7.3

***If you pull up a PHP info page in the browser and its still showing as using PHP 8.1, you can use this command to force the change***

valet use php@7.3 --force
Categories
Fixing Stuff Laravel Mac Samuel

Fixing Dev Environment After Monterey Update

Ok so had a very strange issue come up after upgrading my Macbook to macOS Monterey. To start with I was getting this error anytime I typed php -v on the command line:

zsh: command not found: php

Which obviously that is strange because php is 100% installed on my system. To Fix this we ran:

brew upgrade php

composer global update valet use php@8.1

Everything ran correctly and I now had php 8.1 installed. When I typed php -v it returned my version of php on the command line as it should, but then we ran into a new issue. I pulled up the site I had been working on before this Monterey debacle and got this error message:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.26. in /Users/sam/repos/local-eats-laravel/vendor/composer/platform_check.php on line 24

Ummmm…. what the fuck, over? I’ve got 8.1 installed, it returns from the command line… but my web browser is still stuck using this old outdated php 7.4 (that’s strange) up until this point Valet had always properly taken care of syncing both versions of php. So now we went on the hunt to fix this issue, turns out – easy fix. Just run:

rm ~/.config/valet/valet.sock
valet restart 

This removed a configuration file for Laravel Valet – that I guess was stuck using the old php 7.4 for some reason….. once valet restarted it picked up on the php 8.1 change and were good to go

Categories
Laravel Mac Samuel

Fixing NPM Install Error

Ran into this error today when running NPM install on a project:

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1

To Fix this we ran:

xcode-select --print-path
# in my case /Library/Developer/CommandLineTools

# next line deletes the path returned by the command above
sudo rm -rf $(xcode-select --print-path)

# install the tools(again) with
xcode-select --install

Source: https://stackoverflow.com/questions/60573595/npm-install-fails-on-node-gyp-rebuild-with-gyp-no-xcode-or-clt-version-detec 

Once you complete the commands above now run npm install again and live is good 🙂

Categories
Mac Samuel

Running List Of Shortcuts In Mac Big Sur 11.2.3

Change Host File:

  • Open up terminal and type: sudo nano /etc/hosts
  • Make the needed change in the file to change the host of a website. This is simply writing the IP address of the server, space, the domain name. So in effect it looks like 000.000.00 domain.com
  • Hit control x to close the file. Press Y plus ENTER to save the changes
  • Type: sudo killall -HUP mDNSResponder followed by Return to flush the DNS cache.
  • navigate to the website you want to see

Change Version of PHP in Use With Laravel Valet:

  • Open terminal and navigate to the project you are working on
  • Type: Valet use php@7.2 (or whatever version of PHP you want to activate)

Serving Local Websites From Nested Folder with Laravel Valet:

  • Open iTerminal and navigate to the subfolder where the site lives
  • run valet link folder-name. This will create a symlink to this site so that you can then open up the web browser and type foler-name.test and the site will serve

Opening files in the finder window:

  • option + space to open the alfred search finder
  • ~ + file name, so for example ~ repos gets me to code repo folder
  • once the folder that you want is visible hit command + enter to open it up in the finder winder

Open MySQL from command line & create a new database:

  • from the terminal window type: mysql (this will login to mysql)
  • then type: create database db-name; (replace db-name with the real name of the database you want to create and then press return to create the DB)
  • Once the database has been created open up sequel pro and input the DB name + root and click connect
  • If you need to import a database from staging or live down to local you can do that by clicking file -> import

Ignore a file in any repo – especially useful it the file has been added to gitignore and it is still tracking changes

git update-index --assume-unchanged -- wp-config.php

or you can run:

git update-index --skip-worktree -- wp-config.php

or for a directory you can run:

git update-index --assume-unchanged -- wp-content/plugins/
git update-index --skip-worktree -- wp-content/plugins/

*If you have a really stubborn file you can use:
git update-index --force-remove wp-config.php

Open up Alias file (or any file) with sublim text from the command line:

  • This is pulled from this video: https://laracasts.com/series/setup-a-mac-dev-machine-from-scratch/episodes/7
  • Once you follow the steps in that video you can then run the following command to open the alias file in sublime: subl . ~/.aliases
  • This command can be used to open any file as well just replyce the ~/.aliases with “filename”
  • ***If ever having trouble opening files up with subl . then just open up transmit and the .aliases file will be right there in the local root and just right click and open it up with sublime***

Open up Alias file with Vim

  • vim ~/.aliases
  • press shift i to start inserting new lines
  • when done and ready to save press esc then shift :
  • to quit without saving type q then hit enter
  • to quit and save press wq and then hit enter

Take a screenshot and copy to the clipboard

control + command + shift + 4

Categories
Gitflow Mac Samuel

Updating WordPress Inside A Gitflow Repo

This document is comprised of testing notes while going through the learning process of updating a wordpress site in a repo organized under the gitflow model. The steps below can be followed to update a wordpress site. This document assumes you have MAMP installed locally on your machine.

Generic Useful Commands:
Git branch (shows current branch you are on)
Git branch –a (to list out branches in the repo)
Git status (to see info on our current branch)
Git remote (to see remote branches)
Git tag (to see list of tags)
Git add . (to stage files for a commit)_

Steps Taken to Setup first Gitflow Repo & Update WordPress:

Open terminal and navigate to htdocs:

cd /

This will take us to the actual root directory. Now type:

ls

we should see the full list of folders, including application folder, now type:

cd /Applications/MAMP/htdocs

We should now be in htdocs folder.

Clone the repo

To clone the repo we need to setup git access. Create the keypair following the directions here:
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

Then copy they key into github following the directions here:
https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/

Now Clone the repo down
Navigate to the folder you would like the repo stored in (you should already be in the htdocs folder from steps 1 and 2 above).

Git clone git@github.com:user-name/git-flow-test.git

Now fetch the headers:

Git fetch
Git remote (to see remote branches)

Define who we are in the Repo:
–please note this sets the user for all projects so you will only need to do this once

git config –global user.email your-email-address@your-domain

Create Master Branch:

git checkout -b master
git status (to see if we are on master)

Create Readme.md file
Create readme.md file and put into the repo:
touch readme.md
echo “## This is a markdown readme file” >> readme.md

Complete first commit and push:

Commit this file to the repo
Git add .
Git commit –m “adding readme file”
Git push

–please note if this is your first commit you can select to use the new git 2.0 simple commit type
git config –-global push.default simple

Branch from Master to create Development branch:

git checkout -b dev master

Add old version of wordpress to development:
–please note this is only for testing purposes. In a real life situation the old version of wordpress would already be on the dev branch and we would skip to the step below and create our feature branch from dev

Download old version of wordpress from here: https://wordpress.org/download/release-archive/
Physically move wordpress files into our project folder, then run

git add .
git commit –m “adding wordpress 4.8.1”
git push

— please note on first push we will need to run:
git push –set-upstream origin dev

Branch from development to create new feature branch:

git checkout -b feature/wp-update dev
--Please note feature branches should be named "feature/wp-update" or "feature/some-other-update"

Commit Code To Feature Branch:
–Please note we need to ensure that the local environment is running the same version of php that the client’s live site is running for testing purposes. Update this version in MAMP to mirror the client’s hosting environment

Run the WP install to setup the site:
–use root for local wp site username and root for local password

Run the WP update in WP admin, then run

git add .
git commit –m “updating from wordpress 4.8.1 to 4.8.2”
git push

Merge wp-update feature branch into development branch

git checkout dev
git merge --no-ff feature/wp-update -m “merge wp-update branch into dev”
git push

Branch from dev to create Release branch

git checkout -b release dev

Delete feature Branch

git branch –d feature/wp-update
git push --delete origin feature/wp-update

Merge from release branch into Master
–please note merge from release to master requires final approval from senior dev staff & final client approval

git checkout master
git merge --no-ff release -m “merge wp-update branch into development”
git push

Tag first merge into Master with 1.0.0
–follow semantic versioning numbers http://semver.org/. In this tutorial the first release is tagged with 1.0.0. In a real life situation please note the current version and update accordingly, IIE from 1.0.1 > 1.0.2

git tag -a 1.0.0 –m “updating from wordpress 4.8.1 to 4.8.2”
git push --tags

Helpful links on git tagging:
https://git-scm.com/book/en/v2/Git-Basics-Tagging
https://gist.github.com/justinfrench/89712

General Notes:
WordPress updates do not require database updates to be performed locally. Updating the files on the live server and visiting a few admin pages will perform the database updates on the live server. We should never make updates to a database locally and move that database live. The best possible workflow is one where code moves up and content moves down: https://pantheon.io/docs/pantheon-workflow/

When updating versions of PHP our workflow is:
-clone down site repo to local machine
-update version of php locally
-test site locally to make sure everything works
(if something breaks, create feature branch from dev & make fixes, test locally then merge to development).
-update version of php on development server
-final QA by PM
-merge code to release branch for final approval by senior dev
-update version of PHP on live
-merge code to master from release branch

When updating wordpress versions our workflow is:
-clone down site repo to local machine
-create feature branch from dev and update locally
-test locally to make sure everything works (use php version from clients live site)
-merge to development from release branch
-final QA by PM
-Merge to release branch for final approval by senior dev
-Merge to live

Random Notes:

Writing a commit message without using -m tag:

Press i to enter insert mode.
Now you can type your message, as if you were in a normal (non-modal) text editor.
Press esc to go back to command mode.
Then type :w followed by enter to save.
Finally :q followed by enter to quit.

Deleting Git Tags:

# delete local tag ‘12345’
git tag -d 12345

# delete remote tag ‘12345’
git push –delete origin tagName