Categories
Fixing Stuff Laravel Samuel

Fixing Laravel Error

We had this error display today when trying to deploy a staging site:

Symfony\Component\Debug\Exception\FatalThrowableError  : Class 'Doctrine\DBAL\Driver\PDOMySql\Driver' not found

to fix this issue we connected to the machine via SSH and ran:

composer require doctrine/dbal --with-all-dependencies

This allowed it to install correctly but we were still getting the same error message, solution TBD…

Categories
Laravel Samuel

Setting Up Laravel Forge Staging & Live Machines With Auto Deploy

We are going to break this into three separate sections. Section #1 will be setting up a stand alone Database machine. Section #2 will be setting up a staging and live environment for Laravel sites. Section #3 will be setting up a staging and live environment for WordPress sites.

Section: 1

  • We will be installing a MySQL database server. The documentation on that can be found here: https://docs.digitalocean.com/products/databases/mysql/
  • When creating the database we are going to select the following options from the Forge Screen
    • Type: Database
    • Region: Default
    • Server Size: 4GB Ram, 2 CPU Core, 80 GB SSD
      • This option cost $24/month
    • VPC: we will add it to our company VPC network, all of the other machines will also be added to this network
    • Enable weekly backups: yes

Once the server has been spun up we will save all of the login information that gets emailed to us in our password manager, make a connection to the machine using TablePlus, then delete the email with the passwords.

Making A Connection to the machine using TablePlus:

  • The first thing we will do is go to the SSH screen in forge for the database machine and add our public SSH key. To copy our SSH key from the command line use:
pbcopy < ~/.ssh/id_rsa.pub
  • Once our SSH key has been added to the machine, we can open up TablePlus and create our connection. To do this we will copy the Database Connection URL from the database tab on forge -> open TablePlus and select “create new connection” then select “import from URL”. Note, there is a great video on setup and connecting here: https://www.youtube.com/watch?v=jY5FhyiEdig

Allowing App servers to connect to the DB:

This step can actually only be completed once the other app machines have been created in steps 2 and 3 below, but once you have those created you need to come back to this machine and click into the server -> click network -> then select the option to allow the app machines to connect to the stand alone DB machine.

Section #2:

Laravel staging and live environments. We will create a two separate servers for staging and live. Both of these servers will be “web servers” from the server type drop down menu. We will check the option at the bottom of the page to add servers SSH key to source control providers. Both servers will be added to our company VPC.

Staging: 2GB Ram, 2CPU Core, 60GB SSD – cost $18/month

Live: 4GB Ram, 2 CPU, 80GB SSD – cost 24/month

*Once Both of these Machines are created we need to:

  • Install all our needed versions of PHP
  • Add our SSH key and test our SFTP connections
  • Create a new site with isolated user
    • Note: you must add an ssh key for each isolated user
  • Connect our project repo.
    • Note: we will need to add the servers SSH key and deploy key to the repo.
  • Once the repo is connected we will need to edit the .env file to point to our database machine + set the app_name, app_env, app_debug & app_url
  • we then need to activate our SSL from the SSL tab select lets encrypt
    • Note: we must point the site to the server before obtaining the SSL

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
Samuel Thoughts

A Different Kind Of Company

I want to start a company where the main focus is not a relentless march to make more money. We here this quote all the time “we have a fiduciary responsibility to our shareholders to maximize value”. Some form of that sentence is spoken on just about every quarterly earnings call.

I want to start a company where the focus is on using the money that we make to benefit the largest amount of people that we can. We are going to do this through the products that we build, as well as through the causes that we donate excess money too.

The first product we will build is a platform that allows humans to interface with each other, and where the focus of the business is not the never ending march for more profits. The company will also not be structured so that the lions share of the money ends up being handed out to a small group of board member’s or early employees. No one at the company will ever generate a massive pay day because we will run the company too efficiently, spreading the benefit of the platform to as many people as we can.

The first product we are going to make is a platform that will allow restaurants to interface with their customers more easily and effectively. We are going to take a micro transaction from each order placed on the platform, which will allow the restaurants to have an amazing system because the cost of building and maintaining the platform will be spread out over millions of people (restaurant customers). Restaurants would not be able to afford this system on their own, which causes them to loose out on sales in this post covid word to big chains that can afford excellent apps, and to big silicon vally startups who’s sole goal is to “maximize shareholder value”.

We don’t have to be the first company in the space (were not). We don’t have to have the best technology in the short term. We just have to set out with a lazer focus not on “maximizing shareholder value” but “maximizing value for our systems users and for restaurant owners/staff”. No other company is going to take this approach, and build a tool while not trying to make billions of dollars that we can hoard to ourselves. We are going to make the best possible platform, were going to pay every employee well – including the founders, but everyone including the founders will simply have a very solid salary – ownership and board members will not be making millions per year off this system. We will probably come up with some kind of formula or cap on management salary (current thought is management only gets paid a multiple of employee salaries, like management only gets paid 5x the average salary of all employees). So if all employees on average make 100k, then management would be eligible to make 500k). Not set on the structure of the payment plan but the right setup will show itself as we get this company in motion.

So to summarize; were going to build a platform where restaurants can offer take out and delivery to customers through their own apps. There will also be a central marketplace for consumers to use where they can order from any local restaurant near them. This platform is going to take a micro transaction from each order, making the platform free for restaurants. We will build and maintain their individual apps, including making special one off features for them on their own apps. The restaurants will own their customer list. We will not sell ads on our platform. We will not allow coupons codes on the main central parent app. The company will only generate $ from one source, a micro transaction on each customer order.

After we get this train rolling down the tracks – we are going to attempt to move payments into the blockchain (there will be a separate post outlining the details of this in the future).

Categories
Samuel Thoughts

Where Does A Sports Team Fit Into Society?

I love watching the St. Louis Cardinals, but I am glad that there is a lack of fans showing up to the stadium at the moment.  I realize this might have a slight negatively affect on our players in the short term which sucks – but fan’s are not frustrated with individual players so much as there is a growing frustration about the way the upper management and ownership group are operating. 

This is actually a somewhat common problem in our society where hyper wealthy individuals continue to try and maximize the amount of $ they have instead of looking around and trying to help other members of society out.

Take the cardinals for example: we here it constantly that COVID decimated profits, and before that we heard it year in and year out – we have to keep our payroll down were a smaller market bla bla bla. I don’t understand why local reporters let them get away with that? Fully dig into that statement!  Ask to see their financials or some kinda proof for this, because to the average fan this seems like totally BS.  To the average fan, or at least to me – and I consider myself to be an average, casual fan, this sounds like total BS.  The currently ownership group is making more money off this team than they ever have.  They not only have massive TV deal, they have ownership stakes in the ballpark village complex! They own a freaking massive hotel/condo building + the relatively new and beautiful stadium… I mean I get it – they are running a business like anyone else.  But to me running a sports franchise should operate somewhere between running a standard business and running a charity.  The franchise could do so much good for St. Louis is they turned the dial slightly more 1 or 2 notches to the left and didn’t focus sooo much on making $.  I realize this sounds somewhat strange in America, but they have enough $.  At a certain point does it really matter if you make 300 million dollars or 3 billion dollars? Once you reach into the 10’s of millions of dollars, it’s time to turn around and start looking for ways to lift other people up – you have won at the game we are all playing together.  Making more $ will just be unnecessarily hoarding resources for yourself.  Sure you could buy a mansion or a yacht – or fast cars…. Or whatever! And i”m not saying people should not be free to do this, everyone should 100% be free to do what they want, I’m just saying we should not romanticize that lifestyle. We should be pushing these people with social pressure to help society and the world out as a whole. There is some push towards this with “The Giving Pledge” that Warren buffett has setup – but this falls a little flat.  It’s not that hard to imagine how much good Buffet or other billionaires could do right now if they purchased and re-imaged the goal of the organization they bought.  A really easy example is Buffett could buy a fast food chain –  and chance the payment structure.  They could ensure that the workers at the bottom of the totem pole received an outsized percentage of the profits the company generates.  The company’s mission could change from “maximizing shareholder value” to “maximizing equity in society by prioritizing their poorest workers”.  I’d like to think there are enough rich executives out there that would come work for this chain even thought it would pay them less than they currently make – they would want to be part of this social experiment to try and do better vs pursue unrelenting profits at all costs.  If we could find a balance where this became the main focus, or at least a much larger focus of our society – it would seem that version of capitalism would be the best – most equitable system we could come up with. 

Back to the cardinals front – this ownership group can easily recalibrate the focus of the cardinals, they have more than enough money to do things like: Pay their minor league players a realistic wage, nothing crazy – but just pay the guys like 80 grand a year – that’s not going to kill you.  Sure you don’t need to do it according to the current CBA – but so what the current CBA also doesn’t prevent you from doing this.  It’s the right thing to do. And then at the big league level – spend up to the limit every year trying to make this team as best as you can.  We get it – you won’t hit with every signing, and not every team is going to go deep in the playoffs – but all we want is an honest attempt at putting the players, the city, and all of your fans around the country ahead of trying to generate as much $ as you can for the tiny group of people who own the team.  Your are 100% free to focus solely on $, it’s just deep down I’m sure you know that is a hollow pursuit.  You already have more $ than you could spend, you don’t wan to leave your family so much $ that they never have to work again and become lazy and non contributing members to society.

I hope you consider making some or all of these changes! If