Posts Tagged: php

Use these Credit Card Numbers to Test Paypal Credit Card Payments

I was trying to get Paypal credit card vault to work, but I couldn’t using the generic credit card numbers listed in the documentation. I contacted Paypal support and they said to use these two numbers. VISA : 4716 3248 7603 0777 Mastercard : 5453 9874 8085 6045

Symfony Doctrine To Flush or Not to Flush

I’m in the process of converting an old MySQL database to a shiny new MySQL database controlled via Doctrine. Some of the tables have tens of thousands of records in them, so I was curious if it made sense to flush after each insert, wait till the end and flush or flush periodically during the… Read more »

PHP Soap Server Repeat the Same Element

In a SOAP service I work on, I needed to generate a response that repeated the same element. Something like this. <SOAP-ENV:Envelope xmlns:SOAP-ENV=”http://schemas.xmlsoap.org/soap/envelope/” xmlns:ns1=”http://www.example.com/WebService/”> <SOAP-ENV:Body> <ns1:getPhoneNumbersResponse> <numbers> <number>123341344</number> <number>329822938</number> </numbers> </ns1:getPhoneNumbersResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Getting this to work in the PHP code took a bit of fussing around. You can’t just create a hash, because the… Read more »

Symfony Doctrine Event Listener Silently Fails on instanceof

If you’ve ever done this in a Symfony doctrine event listener if ($entity instanceof User) { // Do something for this particular entity } you might have run across this annoyance. If you forgot to add a “use” statement for your “User” entity in your event listener class, this check will silently fail. I think… Read more »

Symfony Error: Call to a member function format() on string

This Symfony error tripped me up for a few minutes today, it’s not particularly obvious what it’s referring to. Error: Call to a member function format() on string In my case, I was setting a Doctrine entity field to a string when it should have been a DateTime object. In my entity class I defined… Read more »

PHP: To Type Hint or Not

Apparently some people think type hinting with PHP is stupid. I don’t agree. I’ve been writing PHP since PHP version 3 and I think one of the greatest clunk factors in PHP has been that it’s loosely typed. You can never be sure that a string is a string, or is it an integer this… Read more »

Build Unit Tests or Functional Tests?

The headline is a trick – you do both. It’s 2016, if you’re still out there writing code with no unit tests or functional tests, you’re not doing your job correctly. Every time I write a method, I write a unit test. The unit test checks that the method does what I think it should… Read more »

Swiftmailer $record Hash Format

Swiftmailer is cool. It’s a really useful PHP library to make sending email messages really simple. The problem is that it lacks documentation, or the documentation is out there some where, but I can’t find it. One issue that I kept running into was, what’s the structure of the $record hash that the handler’s write()… Read more »