One thing is bothering me though: it guesses form input types from the database column types, which mostly works well but sometimes it picks something that doesn't reflect the way that the user will store information in this field. It's actually pretty easy to change the forms that get generated though, so here's an example. Continue reading
composer.jsonwhere you specify your dependencies
composer.lockwhere composer itself records exactly which precise version of every library and every dependency of every library it picked, so all installs will be identical
composer.lock also includes a hash of the current
composer.json when it updates, so you can always tell if you've added a requirement to the
composer.json file and forgotten to install it. Continue reading
I'm delighted to announce that the second edition of PHP Web Services is published! This isn't an entirely new book but in my own biased opinion it is a much better job of this topic than I did the first time around :) Following from the feedback we got on the first book, this edition contains quite a lot more working examples (with code on github) as well as updates for new tools and expansion on newer technologies and practices.
Writing a second edition was nothing like writing a first edition, it's more like editing with snippets of writing and rewriting thrown in. My heartiest thanks to my tech reviewers who sorted out all kinds of nonsense contradictions and generally asked hard questions during the process - you are all humans of the highest calibre :)
(this drives me nuts, I love upgrading systems but the downside is you have to work with the old ones first and none of the tools you want have been invented yet!)
For OAuth2, all I had to be able to do was to send an
Authorization header with my web request from PHP. My second-favourite way of making API calls from PHP is to use PHP's stream handling, so I did that. It's not code you see very often but it's super-simple and it works on every PHP platform I've tried so far, so here's an example:
// assemble the options $opts = array( 'http'=>array( 'header'=> "Authorization: Bearer " . $access_token ) ); // create the context $context = stream_context_create($opts); // now make the request! Use the context and simply output the result echo file_get_contents('http://api.example.com/endpoint1', false, $context);
If you're trying to make an API call from PHP and installing better tools is hard for any reason, this example may help!