Peter Ha is a seasoned PHP developer at Rōnin. His over 20 years of PHP development experience makes him a true asset to the Rōnin team. He has worked in multiple industries on systems from CMS to EHR and is proficient in various other programming languages such as Python, Java, and Ruby on Rails.
I had the pleasure of sitting with Peter to discuss all things software development and PHP. He had some strong opinions about why PHP development is ideal and how Lavarel is truly the easiest framework to work with for website development.
What inspired you to become a PHP developer?
While I was in college, I found an internship working for a small company that used WordPress and PHP to power its website. I really enjoyed the work and the company. After college, they offered me a full-time position, and I have primarily used PHP since.
Why do you choose PHP as your primary programming language?
Aside from my long tenure working within the language, I find it quicker to go from idea to prototype using PHP. There are fewer hurdles to get started, and everything comes together quickly.
Can you describe a recent project where you used PHP extensively? What were the challenges, and how did you overcome them?
I once worked for a company that manufactured musical instruments. Since they were on the manufacturing side of the equation, they received orders from various retail outlets. We identified that competitors were automating this ordering process, and to stay competitive, our company needed to streamline the process.
I was tasked to build a backend service that would accept and process electronic orders and then create them in the company’s order management system. I used PHP to create an API endpoint to accept the orders, route them to the proper handler to interpret them, and then send an API request to the order management system. The result was a happy company that had significantly optimized its internal ordering process.
What PHP frameworks are you familiar with, and which ones do you prefer?
I have used CakePHP, CodeIgniter, WordPress, Magento, Symphony, and Laravel. While I am comfortable with many of these frameworks, I believe that Laravel is the best PHP framework.
Share an example of a particularly challenging bug you encountered while working on a PHP project and how you resolved it.
I was informed of a bug that was causing certain records from the database to fail. The records in the database were using a random character generator to create the primary key for the database instead of using an auto-incrementing number.
While digging into this problem, I found that three records were failing. For example, one of the primary keys for the failing records was “8479e200504.” The rest of my team could not determine why these records kept falling, but I saw a similar number pattern across the three errors.
I knew that some computer systems used a pattern to represent an exponential (for example, 2e3 would be 2 raised to the third power, 2e3 = 8). When PHP pulled the record from the database, the JSON conversion process tried to convert that pattern into a natural number, which resulted in a number so large that the server ran out of memory.
This large memory string was so large that the server could not log the error. I solved the issue by changing the existing records so that the primary key did not have that pattern. I updated the code so that it would put the ‘:’ character in the middle, and the server did not interpret the string into a large number.
The rest of my team could not determine why these records kept falling, but I saw a similar number pattern across the three errors.
What best practices do you follow to ensure the security of your PHP applications?
Always sanitize data before inserting them into the database. Every time!
Describe a project where you integrated PHP with other technologies or languages. What was the outcome, and how did it benefit the project?
For one project, I used Redis as a cache to improve response time; for another, I used Redis as a Message Queue for local development. Using Redis in these ways, I could provide a simple Message Queue service without connecting to a third-party service.
What do you consider your most successful or favorite PHP project? Why was it memorable or particularly satisfying to work on?
One of the companies I worked for wanted to move to a micro-service architecture. I was given a couple of months to develop a prototype as a proof of concept. I enjoyed this project because it allowed me the flexibility to research the difficulties of moving to micro-services and experiment with various solutions. I was able to make this project my own and provide a solution that was exactly what the company wanted.
Why should someone choose PHP for web development, and in what scenarios is PHP the ideal choice?
I might be partial to PHP for web development because I have been working as a PHP developer for over 20 years, but I’ve stayed with this framework because it offers:
- Faster development
- Robust online community.
- More available PHP developers
- Excellent frameworks like Laravel to work with. Lavarel is a fantastic PHP framework with many practical and relevant features.
To learn more about Rōnin Consulting or to Hire a PHP Developer like Peter for your next project, contact us today.