On the IBM Developer Blog they’ve posted a new article from Lorna Mitchell helping you get started with CouchDB and Guzzle, making use of this popular HTTP client package to interface with CouchDB’s HTTP interface quickly and easily.
In today’s post, we’ll look at how we can use CouchDB in our PHP applications, using the excellent PHP HTTP library Guzzle. Guzzle is a modern, PSR-7 compliant object-oriented PHP library that handles all aspects of HTTP in a correct and — importantly, a scalable — way. So it’s a great way to add any HTTP-interfaced services into your application (PHP 5.5 and later, does support PHP 7).
She then starts off with the installation of Guzzle via Composer and some sample code to make the initial connection to the CouchDB server (either local or remote). With the connection up and working and a "welcome" banner returned, she shows some simple operations like:
- getting a list of all databases
- creating a new database
- inserting and selecting data
- updating and deleting data
Code is provided for each of these and, thankfully, Guzzle makes it a pretty simple process and handles most of the heavy lifting on the HTTP requests for you.
The PHP development group has posted the official release announcements for the latest versions in the PHP 5.6.x and 5.5.x series: PHP 5.6.24 and PHP 5.5.38.
The PHP development team announces the immediate availability of PHP [5.6.24 and 5.6.38]. This is a security release. Several security bugs were fixed in this release. All PHP 5.6 users are encouraged to upgrade to this version.
They also have a quick note that this release for the PHP 5.5.x series is the last in the branch as laid out by the release schedule. Future updates on this branch will only be made if there are major security issues found. Otherwise developers are encouraged to upgrade to the latest versions (5.6.x at the least but really PHP 7.x would be better). You can get these latest releases either from the main downloads page (source) or from windows.php.net for the Windows binaries.
On the TutsPlus.com site there’s a new installment in their "How to Program With Yii2 Series" looking at implementing file uploads with some simple examples.
In this How to Program With Yii2 series, I’m guiding readers in use of the Yii2 Framework for PHP. In this tutorial, I’ll guide you through the basics of uploading files and images in Yii2.
For these examples, we’ll continue to imagine we’re building a framework for posting simple status updates, e.g. our own mini-Twitter. The image above demonstrates writing a short update while uploading a picture I took of the Taj Mahal.
They start with a look at some of the file upload plugins that seemed like the best they found to use with Yii2: FileInput and the 2Amigos BlueImp File Uploader. They go with the first option for the rest of the tutorial, showing you how to get it installed (via Composer), updating your current database tables and changing the model to reflect these updates. Next they help you create the view with the image upload form and one to display the image result once the upload is successful (including the controller code needed).
Loïc Faugeron is back again with the next part of his "Mars Rover" series of tutorials. In this new article he refactors the current code even more to make it more flexible in the long run.
In this series we’re going to build the software of a Mars Rover, according to the following specifications. It will allow us to practice the followings: Monolithic Repositories (MonoRepo), Command / Query Responsibility Segregation (CQRS), Event Sourcing (ES) and Test Driven Development (TDD). Previously we’ve created a navigation package, and in it a LandRover class that validates input parameters for our first use case.
We’ve also started to refactor it by extracting coordinates in their own class. In this article we’re going to further refactor LandRover
He found that the coordinates could become floats (or have additional values) and that the orientation could become an angular degree/be vertical. To help this situation, he pulls this logic out into an
Orientation class. True to the TDD methods, he starts with the phpspec test and generates the skeleton class based on them. He makes some simple edits to make the tests pass and updates the main
LandRover class to use the new
Orientation class for these positions.
The PHP development group has officially announced the release of the latest alpha in the PHP 7.1.x series: PHP 7.1.0 Alpha 3. This is a preview release and should not be used for production applications.
The PHP development team announces the immediate availability of PHP 7.1.0 Alpha 3. This release is the last alpha for 7.1.0. All users of PHP are encouraged to test this version carefully, and report any bugs and incompatibilities in the bug tracking system.
This release includes new features including an Iterable type, HTTP/2 server push support, creating closures from callables and more precise float values. You can see the full list of additions and changes in the NEWS and UPGRADING files. If you’re interested in trying out this latest alpha, you can get the latest source release from here and the Windows binaries here.
The QaFoo blog has a post today about outside-in testing, two design patterns – Adapter and Facade – and how they relate.
As part of our workshops on Test-Driven Development we explain to our customers how testing from the outside-in can help find the right test-mix.
The technique puts a focus on test-driven-development, but instead of the traditional approach starts at the acceptance test level. The first test for a feature is an acceptance test and only then the feature is implemented from the outside classes first. […] Outside-In testing leads to interfaces that are written from what is useful for the client object using them, in contrast to objects that are composed of collaborators that already exist. Because at some point we have to interact with objects that exist already, we will need three techniques to link those newly created interfaces/roles to existing code in our project
These three techniques are:
- using the adapter pattern to interface with third party code
- the facade pattern to "layer" your own code
- continuous refactoring of interfaces/implementations
In this post they focus mostly on the adapter pattern. They show how to use it in interfacing with remote systems in a Symfony application (for example) based on a remote XML file. They also include the test to verify it’s functioning correctly and the PHP code to make the mocks and interfaces you’ll need for the test.
php[architect] Magazine has just published their latest issue for July 2016: Harnessing Magic. This latest issue features articles like:
- "RegEx is Your Friend" (Liam Wiltshire)
- "Removing the Magic with Functional PHP" (David Corona)
- "Implementing Cryptography" (Edward Barnard)
- "Reference Counting : The PDO Case Study" (Gabriel Zerbib)
There’s also all of the usual columns from some of the regular authors, the "Education Station", "Community Corner" and the "Security Corner". If you’re interested in the content but just want a sample, be sure to check out this month’s free article covering mailing lists and MailChimp. You can pick up either just this issue or a full year subscription directly from the php[architect] website.