Categories
Fixing Stuff Laravel Php Storm Samuel

Fixing Laravel Valet Error

Sooooo we needed to jump our local environment from PHP 7.4 to PHP 8.1 in order to work on a different project.

We started by running the command:

Valet use php@8.1

That provided the following error:

Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.1.0". You are running 7.4.27. in /Users/sam/.composer/vendor/composer/platform_check.php on line 25

To fix this issue we ran:

brew link php

This command resulted in:

brew link php
Unlinking /usr/local/Cellar/php@7.4/7.4.27.reinstall... 25 symlinks removed.
Linking /usr/local/Cellar/php/8.1.2.reinstall... 24 symlinks created.

From there we could run “valet use php 8.2” and our new project was happy. This post was also super helpful, it provides solutions for a few other versions oh PHP so if anyone else out there is stuck you can try the link below:

https://dev.to/arielmejiadev/switch-to-older-php-versions-with-laravel-valet-33ph

Categories
Laravel Samuel

Setting up Forge & Envoyer

These are shorthand notes for setting up Forge & Envoyer

Forge:

The first thing we need to do is create the account on Forge. Since we are using Envoyer we need to update the root path, we should also select use Isolation and then type in our domain name. The screen should look like this

Just add our actual domain and then hit add

From there, its time to activate SSL. The domain must be pointed to forge for this to work, so make sure the A record of the domain name is pointing to the forge machine. Click “let’s Encrypt” then type click install.

Now its time to jump over to Envoyer to finish deploying the site:

Envoyer:

  • Hit the Add new project button.
  • Type Live – Site Name
  • Copy username and repo name
  • Copy branch name
  • Click Save project -> then click into the project
  • Click the Server tab, then click Add server
  • Type the Name
  • Copy public IP address from Forge & Enter
  • Connect with port 22
  • connect as the isolated username
  • Select the PHP version we used on Forge
  • Copy the project root path from Forge commands page
  • Leave Blank the check box for reload FPM after deployments
  • Save server, then copy SSH key from Envoyer and add to forge for the isolated user -> test connection
  • Click Manage Environment, copy the .ENV contents into screen and hit save

Setup Deployment Hooks for NPM Install & Run Prod, as well as Clear & Update Cache. The code in these files should look like:

cd {{release}}

npm ci
npm run prod


cd {{release}}

php artisan cache:clear
php artisan view:clear
php artisan config:clear

php artisan config:cache
php artisan route:cache
php artisan view:cache

Finally drag/drop the deployment hooks so that they run before the new release is activated, it will look like this

Categories
Laravel Samuel

Migrate Refresh & Seed With Envoyer

We have been test driving Envoyer and ran into a bit of a stumbling block this week. We have a staging site that we setup to auto deploy with Envoyer. As part of our auto deploy we wanted to run

php artisan migrate:fresh --force --seed

To start we added that code to the Envoyer deployment hook section but it kept spitting out this error when it executed

Could not open input file: artisan

So we realized ok we must be in the wrong location on the server when Envoyer executes this command. It took a little bit of trial and error but we got it working with this:

cd ~/home-directory/current

php artisan migrate:fresh --force --seed

**Replace home-directory above with your real path, so for us we got this by SSHing into the server, and then navigating to the public web directory. If you are using forge this will be super easy as it will be one folder typically named with the URL of your site

Categories
Fixing Stuff Laravel Samuel

Fixing Stuck Forge Deployment

We had a forge deployment get stuck today, took a little searching around but the fix actually ended up being super easy. From the forge dashboard select the self-help drop down -> reset deployment state:

Thats pretty much it, your deployment should stop, and you can look into what was causing the issue. In our case it ended up being incorrect DB credentials in our .env file

Categories
Development Fixing Stuff Samuel WordPress

Fixing Laravel Forge No input file specified

We decided to try and setup WordPress on a Laravel Forge account today, we got everything all setup, pulled up the site and saw this ugly white error screen that read:

No input file specified

As far as errors go it’s not the most useful one. Nothing showed in the logs, after spinning my wheels on this for a while this ended up being very easy to fix, just follow the steps below:

  • Login to your forge account
  • Navigate to the site you are working on
  • Click the Meta tab
  • Change the Web Directory from /Public to /
    • it ends up looking like this

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”