Posts

What the F*ck Is With All the Artisan Commands: Factories

Now that we know how to create tests, it’s time we looked at how we can use factories to generate test data quickly and easily.

Read More

Our New Mailing List!

Our New Mailing List Header Image

We’ve started a new mailing list to communicate new content and links to the community. You can sign up using the form below. We don’t like having our inbox filled up with SPAM so you can be assured that we won’t be sending you any. 😆

Subscribe

* indicates required

View previous campaigns.

Linting All Your PHP Files

The Problem

The PHP CLI has a cool feature (-l) that allows you to check a file to see if it has any syntax errors:

scotts-air:~ scottkeckwarren$ php -l test.php 
Parse error: parse error, expecting `"function (T_FUNCTION)"' in test.php on line 5
Errors parsing test.php

The downside to this is that it doesn’t work on a whole directory. So unless you’re willing to add every new file to a script it’s not a quick way to check all your files before deployment.

The Solution

With some command line magic we can have it run on all the PHP files in our application:

find -L application -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l

I find it helpful to run my template files through this process as well:

find -L application -name '*.phtml' -print0 | xargs -0 -n 1 -P 4 php -l 

Converting Laravel 6.x Migrations to MySQL

Laravel Logo

I’ve had trouble knowing what to put in my migrations’ up() and down() functions. The Laravel Docs include a lot of information but I wanted a quick reference guide for myself to convert Laravel migrations to MySQL commands because that’s what I’m used to. :-)

I also spend some time compiling this into a Cheetsheet if you want a printable version of this post.

Read More

Link Post and Podcast Roundup: January 2020 Edition

Link Post Logo

January’s links.

Read More

Looking Back at 2019 and Looking Forward to 2020

Looking Back at 2019 and Looking Forward to 2020 Header Image

Happy 2020 everyone! As we normally try to do this time of year it’s time take a little retrospective on what’s been done over the last year and what we want to accomplish in the coming year.

Read More

What the F*ck Is With All the Artisan Commands: Make Test

Laravel Logo

Read More

New Layout!

New Layout

Welcome to the new layout for thisprogrammingthing.com! This redesign has been on our minds for a while now and it’s great to be able to finally get it out to everyone!

Setting Up Better PHPUnit to Run Inside a Vagrant VM

PHPUnit Logo

For the last several months, I’ve been using Visual Studio Code for all my PHP projects. I started using Better PHPUnit to run my unit tests because it has a quick keyboard shortcut to run a specific unit test from inside Code. I just set Better PHPUnit up on a new computer I forgot a couple of hoops I had to jump through in order to get it to run inside my Vagrant VM. This post is documentation so I won’t forget and that will hopefully help someone else.

Read More

Link Post and Podcast Roundup: December 2019 Edition

Link Post Logo

December’s links.

Read More
RSS

Join Our Mailing List!

View previous campaigns.

Top Posts

  1. Working With Soft Deletes in Laravel (By Example)
  2. Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
  3. Upgrading to Laravel 8.x
  4. Get The Count of the Number of Users in an AD Group
  5. Multiple Vagrant VMs in One Vagrantfile
  6. Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
  7. Changing the Directory Vagrant Stores the VMs In
  8. Accepting Android SDK Licenses From The OSX Command Line
  9. Fixing the 'Target class [config] does not exist' Error
  10. Using Rectangle to Manage MacOS Windows

subscribe via RSS

All content copyright This Programming Thing 2012 - 2021
Blogging about PHP, MySQL, Zend Framework, MySQL, Server Administration and Programming in general