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 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.
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.
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.
The SitePoint PHP blog has posted a tutorial continuing on from some previous advice with even more defensive programming practices you can use in your PHP applications.
Many people argue against defensive programming, but this is often because of the types of methods they have seen espoused by some as defensive programming. Defensive programming should not be viewed as a way to avoid test driven development or as a way to simply compensate for failures and move on. […] What are these methods, if not ways to anticipate that your program may fail, and either prevent those, or else ways in which to handle those failures appropriately?
They go on to talk about the ideas of "failing fast" when errors happen in your application with an extra suggestion added on – "fail loud" too. The tutorial then looks at four different places where more defensive programming techniques can be applied (and how):
- Input validation
- Preventing Accidental Assignment in Comparisons
- Dealing with Try/Catch and Exceptions
They end with a recommendation that, while you should fail fast and loud when issues come up, be sure it’s not to the determent of the overall user experience or sharing messages with users that may just confuse them.
The SitePoint PHP blog has published the first edition of their "Sourcehunt" effort, sharing several PHP libraries to promote them and give them wider exposure to the community at large. In this post they talk about tools covering a wide range of functionality including cryptography, validation, user agent parsing and "humanizing" strings.
Last month, we introduced a new effort called Sourcehunt – a category of post intended to direct attention to less popular open source projects that show promise and need exposure. We’ve called for new submissions and accumulated an impressive list.
Included in their list for this edition are tools like:
…and many more. A summary of the features, code and output examples are provided for most of the tools mentioned and the number of GitHub stars at the time of the posting is listed next to each library name.
On the SitePoint PHP Blog Jeff Smith introduces Flarum, a project that bills itself as "forums made simple" that’s easy to set up and includes both the standard features you’d expect from a forum and some interesting "power" ones as well.
[Flarum](http://flarum.org) is a forums solution that is currently in public beta and is under active development. Today we’re going to take a look at it, get it set up in a [Homestead Improved](http://www.sitepoint.com/quick-tip-get-homestead-vagrant-vm-running) Vagrant virtual machine, and look at the configuration and the features that Flarum offers. Then, we’ll compare it to some other forums platforms to see how it stacks up at a glance.
They start with a bit of environment setup including the creation of the Homestead virtual machine. The tutorial then roughly follows the installation guide and helps you get the software installed, the web server configured and configuring the software via the Admin interface. They help you set up some of the basics, permissions, change the appearance of the site and work with tags and extensions. They get more into this last topic, introducing some of the things you can customize in the layout and links to more information on both extensions and themes. The post ends with a brief overview of some of the general features that the forum offers including it being touch friendly, "friendly" URLs and easy moderation functionality.
On the SitePoint PHP blog they’ve posted a tutorial from author Nicola Pietroluongo that wants to help demystify regular expressions with a few more real-world examples. He doesn’t teach the foundations of regular expressions here and instead opts for a more "cookbook" approach with lots of little examples.
A regular expression is a sequence of characters used for parsing and manipulating strings. They are often used to perform searches, replace substrings and validate string data. This article provides tips, tricks, resources and steps for going through intricate regular expressions.
He starts with some basic tips around creating good regular expressions for your application: knowing the scenario you’re matching, planning the requirements and implementing the match itself. His example expressions include matching for:
- simple passwords matching a policy
- valid URL matching
- HTML tag patterns
- finding duplicated words
Each example comes with the regular expression itself and an explanation of how it’s doing the matching, breaking it down into each piece of the regex puzzle and how it relates to the match overall.