The SitePoint PHP blog has a new tutorial posted helping those Sculpin users out there get the most from their site with some helpful customization tips. Sculpin is a PHP-based static site generation tool that converts Mardon files and Twig templates into HTML documents ready for use.
If you’re a PHP developer and currently running a blog with a static site generator such as Octopress or Jekyll, wouldn’t it be great if you could use your primary language for it? Yes, it’s healthy for us developers to use more than one language, but let’s be honest – we often want to add some functionality to our blogs, but it’s difficult to accomplish in unfamiliar syntax. In this article, we’ll set up Sculpin, a static site generator for PHP. Just like any other static site generator, it uses markdown files and HTML templates to generate your blog, so the transition should be easy.
The tutorial starts by helping you get Sculpin installed (as a phar executable) and move it to where it’s globally accessible. With that installed the article then helps you make a simple blog, customize some of the basic settings and start in on a new blog post. With that in place it then gets into the customization, adding in:
- syntax highlighting
- Disqus commenting
- blog archive links
The post finishes up showing you how to deploy the resulting blog into a GitHub pages repository and pushing them out for public consumption.
The Laravel News site has posted an interesting tutorial where they describe the use of WordPress as a backend for a Laravel application. This setup is based on the Laravel News‘ own experience with it in the recent refactoring of the site.
Last week I relaunched Laravel News, and the new site is running on Laravel with WordPress as the backend. I’ve been using WordPress for the past two years, and I’ve grown to enjoy the features that it provides. The publishing experience, the media manager, the mobile app, and Jetpack for tracking stats.
I wasn’t ready to give these features up, and I didn’t have the time to build my own system, so I decided to keep WordPress and just use an API plugin to pull all the content I needed out, then store it in my Laravel application. In this tutorial, I wanted to outline how I set it all up.
While he did find other methods for linking the two, they didn’t quite fit with what he wanted so he worked up his own. The content is then synced via a recurring task pulling over posts, categories and tags. He gets into the WordPress REST API first, showing the extraction of the posts from the API and pushing them into a Laravel collection. There’s also an example of how to sync a post with the database (API) and how to create a new post in a similar way. Also included is the code to get the featured image, get the category for a post and sync the tag values. The tutorial finishes with the code for the sync command and pushing it into the scheduler.
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.