Curl Error Using Guzzle using Laravel Valet and Passport

This is a niche issue with: Laravel, Valet, Passport, Guzzle, Curl, API If you’re using Laravel Passport and you’re doing something like this: use GuzzleHttp\Client; try { $client = new Client(); $client->post(‘site.test/oath/token’, [some params]); And you get an error “Laravel guzzle cURL error 6: Could not resolve host” while making an api post request. Check … Read more

Setting Up Virtual Hosts on a Mac

I ran into some trouble running through different tutorials to setup virtual hosts while setting up a local Laravel site. There doesn’t seem to be much consensus on the developers’ preferred local environment. So here’s how to setup virtual hosts on a mac with MAMP. From what I understand this let’s you use a “virtual” … Read more

PHP File Handling Cheat Sheet

Accessing Directory Read Directory Files into Array $dir = ‘example’; $files = scandir($dir, ‘w’) or die(‘Cannot read directory: ‘.$dir); //implicitly creates file foreach ($files as $file) { //do something with $file } Open and Close Directory $dir = ‘example’; if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) … Read more

Contact Form 7 Ticketing Plugin

The CF7 Ticketing Plugin is an incomplete plugin made for a client that needs a ticketing system for building maintenance. It utilizes the Contact Form 7 plugin for form validation and stores the input as a custom post type that can be searched and organized. CF7-Support-Ticket Plugin The plugin includes a custom backend menu, “Tickets”, … Read more

Simple Regex Reference

A simple regex reference sheet for all your regex needs. [abc]     A single character: a, b or c[^abc]     Any single character but a, b, or c[a-z]     Any single character in the range a-z[a-zA-Z]     Any single character in the range a-z or A-Z^     Start of line$     End of line\A     … Read more

Using Prepared Placeholders with Wildcards in PDO

When using SQL wildcards with PDO placeholders, include the wildcard in the variable and not the query. Use this: $search = ‘%’ . $search_term . ‘%’; $sql = “SELECT * FROM posts WHERE content LIKE :search”; $stmt = $pdo->prepare($sql); $stmt->bindParam(‘:search’, $search, PDO::PARAM_STR); $stmt->execute();

SQL Cheat Sheet

This is a handy cheat sheet for simple SQL reporting. Ordering Columns Ordering by a single column criteria: SELECT * FROM <table name> ORDER BY <column> [ASC|DESC]; ASC is used to order results in ascending order. DESC is used to order results in descending order. Examples: SELECT * FROM books ORDER BY title ASC;SELECT * … Read more

Learning Progress Part II

The Progress So it’s been almost two and a half months since I started learning how to code. During that time I’ve finished the Beginning PHP and Development for WordPress tracks on Team Treehouse. Before starting another track I wanted to make sure I had integrated what I learned. So I made projects for myself … Read more

WordPress $wpdb Object Overview

This is a really helpful overview from BenBaltar on how to run a query on the $wpdb. I personally used this when I created a function within a plugin to check if a post was a child of an array of posts. One question I have is if it is the most efficient use of … Read more