Pragmatism in the real world

Custom OAuth2 authentication in Apiiglity

I have a client that's writing an Apigility API that needs to talk to a database that's already in place. This also includes the users table that is to be used with Apigility's OAuth2 authentication. Getting Apigility's OAuth2 integration to talk to a specific table name is quite easy. Simply add this config: 'storage_settings' => array( 'user_table' => 'user', ), To the relevant adapter within zf-mvc-auth => authentication config. However, if you want to use… continue reading.

Replacing Pimple in a Slim 3 application

One feature of Slim 3 is that the DI container is loosely coupled to the core framework. This is done in two ways: The App composes the container instance rather than extending from it. Internally, App depends on the container implementing the container-interop interface. You can see this decoupling in the way that you instantiate a Slim 3 application: $settings = []; $container = new Slim\Container($settings); $app = new Slim\App($container); Slim 3 ships with Pimple… continue reading.

Debugging PHP SOAP over SSL using Charles

I'm currently integrating against a SOAP server using PHP which wasn't working as I expected, so I wanted to find out what was happening over the wire. I have Charles installed and use it regularly with OS X's system-wide proxy settings. However, PHP's SoapClient doesn't use these, so I had to work out how to do it manually. Enabling SoapClient to send via a proxy is really easy and is documented by Lorna Mitchell in… continue reading.

First beta of Slim Framework 3

Last night, I tagged beta 1 of Slim Framework 3! This is a significant upgrade to v2 with a number of changes that you can read on the Slim blog. For me, the two key features that I'm most excited about are: PSR-7 support, along with the standard middleware signature of:     function($request, $response, $next) { return $response; } Dependency injection container with container-interop compliance. We ship with Pimple by default, but I'm planning to use… continue reading.

Selecting the service port with PHP's SoapClient

I'm currently integrating with a SOAP service which has two different services defined. The relevant part of the WSDL is: <wsdl:service name="Config"> <wsdl:port name="BasicHttpBinding_IConfiguration" binding="tns:BasicHttpBinding_IConfiguration"> <soap:address location="http://nonsecure.example.com/Configuration.svc"/> </wsdl:port> <wsdl:port name="BasicHttpsBinding_IConfiguration" binding="tns:BasicHttpsBinding_IConfiguration"> <soap:address location="https://secure.example.com/Configuration.svc"/> </wsdl:port> </wsdl:service> I discovered that PHP's SoapClient will select the first port it encounters and doesn't provide a way to select another one. This was a nuisance as I wanted to use the SSL one. Through research, I discovered that I can… continue reading.

Accessing services in Slim 3

One of the changes between Slim Framework 2 and 3 is that the application singleton has gone. In Slim 2, you could do this: $app = \Slim\Slim::getInstance(); // do something with $app In general, you didn't need access to $app itself, but rather you wanted access to something that the app knows about, such as a database adapter, or the router for access to the urlFor method to create a URL to a route. With… continue reading.

Testing my ZF1 app on PHP 7

Zend Framework 1 is still actively maintained and we fully intend to ensure that ZF1 works with no problems on PHP 7 when its released. Now that PHP 7.0.0 Alpha 1 has been released, it's time to find out if your Zend Framework 1 app works with it. The easiest way to do this is to use a virtual machine. My preference is Vagrant with Rasmus' PHP7dev box. A simple VM I wanted to test… continue reading.

Brent Simmons: How Not to Crash #9: Mindset

Brent Simmons has recently posted How Not to Crash #9: Mindset: I used to think that means I should write code that’s about 80% as clever as I am. Save a little bit for debugging. But over the years I’ve come to think that I should write code that’s about 10% as clever as I am. And I’ve come to believe that true cleverness is in making code so clear and obvious that it looks… continue reading.

20 years of PHP

Today marks 20 years since PHP was released by Rasmus Lerdorf and Ben has been asking for how we started our PHP journey. My first use of PHP was to write a website for an online computer gaming guild for EverQuest, back in 1999. A friend recommended it when I asked him how people programmed webpages in something other the C! That first website is still going and I'm not proud of the code. I'm… continue reading.

My Xdebug configuration

With the release of Xdebug 2.3, I have updated my xdebug php.ini settings, so it seems sensible to write them down where I won't lose them! The new-for-2.3 features which prompted this are xdebug.overload_var_dump, which Derick has written about and xdebug.halt_level which I have previously written about. I find both of these very useful. This is my current php.ini configuration: ; Xdebug settings ; var_dump() displays everything, including filename and line number xdebug.overload_var_dump = 2… continue reading.