Category: Tutorial

  • Your Password Hashing Algorithm Is Bad And You Should Feel Bad

    Your Password Hashing Algorithm Is Bad And You Should Feel Bad

    No Where md5() = sha1(), base64_encode(), etc. This type of password hashing is still widespread and susceptible to rainbow table attacks. Yes (Source) Uses bcrypt, this particular implementation auto-magically hardens itself over time. How to use You are responsible for new \Pdo(), $condition, maybe asking the user to make their ‘password’ not suck. Read the snippet and reason about it. Don’t just copy/paste, it won’t work. Keep on…

  • Git Squash at the Command Line with a Bash Script

    Git Squash at the Command Line with a Bash Script

    Useful if the commits on your branch are sloppy, and you want to clean them up, and you don’t mind that your new commits will be file based instead of time based. What does that mean exactly? Let’s say you worked two days on 3 files. (One of the files was a class, another a config, and the…

  • PHP and Go, Together at Last!

    PHP and Go, Together at Last!

    This blog post is about Spiral Framework and Roadrunner Server. I’ll briefly talk about what they are, then show how to compile a custom Roadrunner server, start developing with Spiral, using Docker. Explain Like I’m 5 PHP Developers Roadrunner works by creating a HTTP server with Golang’s excellent net/http package, and using Goridge as a bridge to pass PSR7 Request and Responses between…

  • Using MySQL Deadlocks To Avoid Overselling

    Using MySQL Deadlocks To Avoid Overselling

    When developing an e-commerce application, you generally want to avoid overselling. First attempt, creating deadlocks MySQL has 4 transaction isolation levels: SERIALIZABLE, REPEATABLE READ, READ UNCOMMITTED, READ COMMITTED. In the following proof of concept, where we have 50 of the same product in stock, and we run seige to represent concurrent customers buying the same…

  • Refactor Your Slow Form Using PHP Generators and Event Streams

    Refactor Your Slow Form Using PHP Generators and Event Streams

    Your form will still be slow but the user experience will be better. They will see a progress bar and see status updates in real time. The idea is to refactor something like this: Into this: And this: Before Imagine you have this form somewhere on your corporate intranet. The user clicks submit. They wait,…

  • Password Protect WordPress Admin With .htaccess

    Password Protect WordPress Admin With .htaccess

    The wp-admin panel is already password protected in that you are required to login. Sometimes that’s not good enough. This tutorial explains how to add an additional layer of authentication to the login process, essentially blocking wp-login.php requests from annoying bots or other malicious users. Step 1: Create a `/path/to/.htpasswd` file. Step 2: Create a…

  • Install Upgraded GNU Bash on a Macbook Pro

    Install Upgraded GNU Bash on a Macbook Pro

    When you get a new Macbook Pro with M1 chip you get an old version of Bash. Bash isn’t old. It’s still being maintained. It has millions of Linux and Windows users. Here’s how to put the newest version of Bash back inside your MacOS box. Prerequisite: Install Homebrew. (Install iTerm2 for good measure.) Install…

  • Building a Simple API using Opulence PHP

    Building a Simple API using Opulence PHP

    This tutorial will show you how to code a simple JSON API using Opulence PHP. We will install Opulence’s skeleton project using composer, then create a ‘user’ database entity, and finally we will match CRUD (Create, Read, Update, Delete) to POST, GET, PUT, and DELETE. Prerequisites: PHP7, Composer, MySQL. Installing Create an Opulence project with the following command:…

  • Install PHP7 and Composer on Windows 10

    Install PHP7 and Composer on Windows 10

    PHP7 is a general purpose scripting language well suited for web development. Composer is the defacto package manager for PHP7. This tutorial will show you how to install PHP7 and Composer on Windows 10 for use in a command prompt. A common misconception is that you need a web server like IIS, Apache, or Nginx…

  • Install Phalcon PHP On Windows 10

    Install Phalcon PHP On Windows 10

    A common misconception is that you need a web server like IIS, Apache, or Nginx to get started with PHP7 development. In fact, PHP7 has its own built in web server that you can invoke at the command prompt. Many modern PHP frameworks support this, such as Phalcon PHP. PHP7 and Composer on Windows 10…