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.
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 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.
On the SitePoint PHP blog there’s a new tutorial posted showing you how to use the Halite package to encrypt the contents of emails. The Halite library sits on top of the libsodium functionality to provide tested, hardened cryptographic results.
Cryptography is a complex matter. In fact, there is one golden rule: „Don’t implement cryptography yourself.“ The reason for this is that so many things can go wrong while implementing it, the slightest error can generate a vulnerability and if you look away, your precious data can be read by someone else.
[…] Some libraries out there implement cryptography primitives and operations, and leave a lot of decisions to the developer. […] Nevertheless, there is one library that stands out from the rest for its simplicity and takes a lot of responsibility from the developer on the best practices, in addition to using the libsodium library. In this article we are going to explore Halite.
The tutorial then starts of helping you get the libsodium package installed on your system (assuming it’s unix-based). They then start on the sample application – a basic "email" client able to send/receive messages between users. They set up RESTful endpoints to get the messages, use the Doctrine ORM for a database interface and show the use of the Halite
Crypto class to encrypt/decrypt the message contents.
On the SitePoint PHP blog there’s a new tutorial posted from Bruno Skvorc showing you how to use Nitpick CI to "nitpick" over coding standards and rules in your PHP code.
There are many ways to make sure your code respects a given code standard – we’ve covered several before. But enforcing a standard team-wide and making sure everyone knows about mistakes before they’re applied to the project isn’t something that’s very easy to do. Travis and Jenkins can both be configured to do these checks, but aren’t as easygoing about it as the solution we’re about to look at: Nitpick CI.
He starts by getting a sample project bootstrapped and pushes it up to GitHub so the Nitpick service can access it. He then switches over to the Nitpick side and shows the setup of an account and a new project pointing to the newly created repo. He then includes the process and results of two kinds of pushes: non-code (README update) and both a valid/invalid code update. He shows examples of the comments the Nitpick service makes directly on the code and a patch to fix the issues.
The SitePoint PHP blog has a post to their site introducing SparkPost, an email delivery service (in the same vein as Mandrill) that you can hook into your PHP applications to prevent the need to run your own mail servers.
I’ve used Mandrill for as long as I can remember. It sends transactional email, like the kind you receive when you sign up for a new account. Like me, many have been happy to use a free account for sending a relatively low number of emails a month. That is, until recently, when Mandrill caused a bit of a stir. The heart of the matter is that Mandrill removed their free tier. Anybody wishing to send mail through Mandrill now requires a paid-for MailChimp account
[…] Mindful that people are looking for alternatives (to power their personal newsletters or whatever), I spoke to Aydrian Howard. Aydrian is the Developer Advocate at SparkPost, whom I met at FluentConf. We talked for a bit about SparkPost and what makes it different from MailChimp.
After the little bit of Q&A about the service, the tutorial gets in and shows you how to get SparkPost set up for your application. They help you install their own client library and send a first test email using your account. Code is provided showing the configuration of the client with your key and the options you can define when sending the message.
On the Cloudways blog they have a new tutorial posted showing you how to use memcached with PHP to help improve the overall performance of your application through cached data.
Memcached is a distributed memory caching system. It speeds up websites having large dynamic databasing by storing database object in Dynamic Memory to reduce the pressure on a server whenever an external data source requests a read. A memcached layer reduces the number of times database requests are made.
[..] Why Memcached? It increases the response time of your web pages, which in return enhances the overall customer’s experience. A better response time allows users to fetch data seamlessly.
He starts by ensuring that you already have a memcached instance up and running (it’s external to PHP). They suggest using their own Cloudways setup, but it’s relatively easy to install with packages on most Linux distributions. With that verified, he shows how to check for memchace functionality in your PHP installation and provides a bit of code to create a connection. Next is an example showing how to pull information from a MySQL database and push that data directly into the waiting memcache server via a
set method call. It also includes a
get example, showing if the caching was a success or not.
The SitePoint PHP blog has a new tutorial for the Composer users out there talking about Composer plugin development and how they can add functionality to this already powerful tool.
Composer is the sharpest tool in the toolbox of the modern PHP developer. The days of manual dependency management are in the distant past, and in their place we have wonderful things like Semver. Things that help us sleep at night, because we can update our dependencies without smashing rocks together.
[…] Even though we use Composer so frequently, there’s not a lot of shared knowledge about how to extend it. […] Yet, recent changes have made it much easier to develop Composer plugins. […] So, today I thought we would explore the possibilities of Composer plugin development, and create a fresh bit of documentation as we go.
He walks you through the creation of a simple plugin: one that tracks users and the dependencies they require. He shows you how to create the initial plugin boilerplate and the creation of the
activate methods. These grab the dependencies being added and send the information off to a remote site.
On the Semaphore CI blog they’ve posted a great tutorial that wants to help you Docker-ize your PHP application and deploy the application easily out to Heroku (with some help from Semaphore, naturally).
In this tutorial, you will learn what Docker is and how you can use it to create sophisticated working environments. If you already have experience using VMs such as VirtualBox, Vagrant, etc., you’ll grasp the concept quickly.
To make things more concrete, we will use a demo application which interacts with the 500px API to list popular photos, view, upvote and comment on them. The application is built using Laravel 4, but this shouldn’t present an issue in our case.
They start with a brief introduction to what Docker is for those not familiar with the technology and some of the requirements you’ll need to use it. They help you get Docker installed on your local system and how to work with Docker images and containers to create a custom environment for the Laravel application. Next, he talks about Dockerfiles (configurations for Docker), spinning up the environment and an alternative to manual commands: Docker YAML configuration. The next move is to deploy to Heroku using the "heroku‘ command line tool and integrating it all with Semaphore for continuous deployment.
The SitePoint PHP blog has posted a tutorial showing you how to build something that’s become an integral part of most frameworks and applications practicing modern PHP development: a dependency injection container.
A search for “dependency injection container” on packagist currently provides over 95 pages of results. It is safe to say that this particular “wheel” has been invented.
However, no chef ever learned to cook using only ready meals. Likewise, no developer ever learned programming using only “ready code”. In this article, we are going to learn how to make a simple dependency injection container package.
He walks you through the entire process of creating the container and each of the pieces that make it up:
- the overall interface for the container (with has/get methods)
- having it cooperate with the "container interoperability" structure
- reference handling
- constructor injection functionality
Code is included the whole way showing you how to create the parts and fit them together to make more of a whole. He ends the post with a look at a few other dependency injection containers and a reference to the repository with the end result of the article.