Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Laravel News:
Data-driven testing with PHPUnit
Feb 27, 2018 @ 17:54:24

The Laravel News site has a tutorial posted that approaches a common development task - writing tests - from a data-driven approach rather than a strictly functional one.

Testing your code is an essential part of the development process, but sometimes it could also be expensive when you try to emulate many uses cases based on a set of different input data.

In many cases, you could end up with a massive directory of tests repeating the same block of code over and over for each possible user interaction.

They start with an example of a feature to test (Markdown parsing) and how traditional testing would have methods for each of the transformations. With a data-driven approach they turn the tests around and make use of data providers to set up the initial string, transformer to use and the correct result. Code is included showing an example of this kind of testing for the same Markdown parsing example and what a failure would look like in a dataset with multiple items.

tagged: tutorial provider phpunit testing data datadriven markdown

Link: https://laravel-news.com/data-driven-testing-phpunit

Laravel News:
In Laravel 5.4 You Can Use Markdown in Your Emails
Dec 14, 2016 @ 16:19:10

As is mentioned in this post on the Laravel News site one of the improvements coming in Laravel v5.4 will be the ability to use Markdown formatting in your emails.

Laravel 5.3 introduced two new features around email, the Mailables and Notifications which allow you to send the same message through email, SMS, and other channels.

Building on top of these improvements, Laravel 5.4 is going to include a brand new Markdown system for creating email templates.

Under the hood, this feature implements the Parsedown parser with its companion, Markdown Extra so you can use tables.

They go on to describe how this feature is integrated with the "components and slots" handling also recently introduced in the framework for things like headers, messages, layouts and tables. Also included is some example code showing how to return the Markdown parsed version of a view, using them in notifications and how to use inline styling.

tagged: laravel markdown email mailable formatting output tutorial v54 framework

Link: https://laravel-news.com/laravel-markdown-emails

Colin O'Dell:
Optimizing league/commonmark with Blackfire.io
Jan 06, 2016 @ 18:47:38

Colin O'Dell has a post to his site talking about how he used the Blackfire.io service to optimize league/commonmark, a library that's a part of The PHP League making it easier to work with Markdown content in PHP.

As you may know, I am the author and maintainer of the PHP League's CommonMark Markdown parser. [...] This last goal [of being well-written and super-extensible so that others can add their own functionality] is perhaps the most challenging, especially from a performance perspective. Other popular Markdown parsers are built using single classes with massive regex functions.

He shares some brief benchmarks of parsing the same document with four different parsers, including an older version of CommomMark (coming in last, unfortunately). With the goal of optimization in mind, he tried out the Blackfire.io service to locate the bottlenecks in his library. Based on the results from the tests he found two optimizations that could be made relatively easily: switching from single-character parsing to regex and more correctly replacing newlines with breaks where needed.

tagged: commonmark blackfireio profile phpleague package markdown

Link: http://www.colinodell.com/blog/2015-11/optimizing-league-commonmark-blackfire-io

SitePoint PHP Blog:
Using Sphinx for PHP Project Documentation
Aug 17, 2015 @ 14:19:04

The SitePoint PHP blog has posted a guide to using Sphinx, a documentation generation tool that's used behind the scenes for the ReadTheDocs hosted documentation service.

I recently had the need to write proper prose-like source-code documentation for the Diffbot PHP client. Having looked at several documentation generators, and even having suggested a @prose tag for importing of related MD/reST documents into method and class descriptions, I realized there simply is no perfect solution we can all agree on (yet). So until I extend Sage with a @prose token and reST parsing, I opted for ReadTheDocs and Sphinx.

He starts with a quick "TL;DR" of the necessary commands to get things working quickly but follows it with the full details. He walks you through the installation of Sphinx locally, setting up the folders and adding a custom theme. He show how to create the table of contents, activate the PHP syntax highlighting and how to show/hide the "Edit on GitHub" links. He also includes the steps to convert Markdown documents into the reST format and, finally, adding the project to the ReadTheDocs site and pushing your results.

tagged: sphinx project documentation tutorial readthedocs markdown rest

Link: http://www.sitepoint.com/using-sphinx-for-php-project-documentation/

SitePoint PHP Blog:
Building a Micro Markdown API App with Lumen
May 12, 2015 @ 15:35:57

The SitePoint PHP blog has a new tutorial posted showing you how to create a small API service with Lumen, the recently released microframework from the creators of Laravel. Their example service takes in Markdown content and translates it to be returned as JSON.

If you’ve been using Laravel for a while, you know that it sometimes feels a little heavy for a small application or service. For that same purpose, Taylor, the creator of Laravel built Lumen. A small micro-framework built on top of Laravel Illuminate components, it doesn’t load all the components by default like Eloquent, Blade, Middleware, etc, remaining light as it boots up. We will explore all of that this short tutorial. [...] To illustrate a practical use case for the micro framework, we will be creating a Markdown parser API application where the user can submit a Markdown text and get back the parsed content as JSON. I will be using the league/commonmark package from the PHP League.

They walk you through the installation of a Lumen instance (via Composer) and how to build out the folder structure for things like resources, database configuration and views. They then include the code for the route and controller to take in the Markdown content and translate it out to HTML as a first step. Then they use the same functionality and return the HTML result as a JSON document. Also included is a simple few line call with Guzzle to the API to pass in a Markdown file and fetch the result.

tagged: tutorial markdown lumen microframework commonmark translate api microservice

Link: http://www.sitepoint.com/building-micro-markdown-api-app-lumen/

Paul Jones:
Bookdown: DocBook-Like HTML Output From Markdown
Mar 05, 2015 @ 16:49:27

Paul Jones has posted about a new tool he's worked up specifically for authors looking to write using Markdown and wanting it to generate out like DocBook results. His tool, Bookdown, uses Markdown and JSON files instead of XML configurations.

Yes, I know, there’s a ton of static site generators for PHP out there already [...but they're] not DocBook-like documentation. By “DocBook-like”, I mean (among other things) numbered headers, auto-generated tables-of-contents on their own pages, hierarchical multi-page presentation, and the next/previous/up linking at the top and bottom of pages.

[...] So: Bookdown. This scratches my particular itch, with very few dependencies. Bookdown, although it can be used as a site generator, is only incidentally a site generator. What it really is is a page generator, with the idea that you can integrate the pages into any other site you want.

The library is separate from the project and is written to use a dependency injection methodology to keep things decoupled and well-structured. If this sounds interesting either for personal use or if you'd like to check out the code, head over to the project site for more information.

tagged: markdown bookdown library project docbook output static generator

Link: http://paul-m-jones.com/archives/6088

Developer Drive:
Simplify your documentation process with Couscous
Dec 19, 2014 @ 18:14:49

On the Developer Drive site today there's a quick post introducing you to Couscous, a PHP-based documentation generation tool. Couscous translates your Markdown files into HTML output that's professional and clean looking.

If there’s one thing I hate more than tracking down bugs, it’s documenting code. It takes forever, it’s almost a project in itself, and I never seem to factor it into my project lifecycle. Setting out to solve that problem for me, and anyone else whose life is too short, is Couscous. Couscous takes markdown files and converts them into professional standard HTML docs that colleagues, or fellow developers, can easily follow. You can preview the resulting site on your local machine, correct any issues, and then deploy straight to GitHub where it will be hosted for you.

They walk you through the (brief) process of getting the tool installed via Composer and using it to show you a preview of your documentation. The "deploy" command then allows you to easily deploy the results out to a GitHub Pages location on the gh-pages branch. You can find out more about Couscous on the project website.

tagged: documentation couscous tool markdown generate html output

Link: http://www.developerdrive.com/2014/12/simplify-your-documentation-process-with-couscous/

NetTuts.com:
Statamic 101
Dec 11, 2013 @ 16:40:41

NetTuts.com has a new tutorial posted today introducing you to Statamic, a PHP-based content management system that uses flat-files instead of database entries to manage its content. (One note, Statamic is not free software and there's no "trial" version)

Statamic is a modern PHP CMS which really makes an effort to be easy and intuitive to use. From its flat-file design to its use of technologies, like markdown and Yaml, you can accomplish an outstanding amount of work without writing any code at all. In this article we will take a look at the process from installation to setting up a basic portfolio.

The CMS (downloadable here) has a simpler structure than some other systems as most of the content is just files in the "_content" directory. They talk some about the directory structure of the tool and help you get things configured via the main YAML config. The post then moves on to working with themes and how to get dynamic content in a basic layout. From there they go on to talk about making new content, adding entries and various other topics like administration and templating.

tagged: statamic cms introduction file markdown template layout content

Link: http://net.tutsplus.com/tutorials/php/statamic-101

SitePoint PHP Blog:
Using PHP Streams Effectively
Nov 21, 2013 @ 17:54:02

Vito Tardia has a new tutorial posted to the SitePoint PHP blog today showing you how to use PHP streams effectively, a continuation of his streams series started here.

n my previous article we've discovered the basics of PHP Streams and how powerful they were. In this tutorial we are going to use this power in the real world. First I'll show you how to build your custom filters and attach them to a stream, then we'll package our filters inside a document parser application.

He starts out by introducing the concept of filters in streams - bits of code that can be attached to the stream to perform operations on the data traveling through it. He includes a simple base64 encoding example with a fopen call to illustrate. He gets into more complex filtering by creating a Markdown filter capable of translating the incoming Markdown-formatted data into a document using the MarkdownExtra library. He also includes an example of another filter added on post-Markdown conversion, a Template filter using the RainTPL templating library.

tagged: using streams filter markdown template tutorial

Link: http://www.sitepoint.com/using-php-streams-effectively/

Hannes Magnusson:
New PHP.net designs floating around
Sep 06, 2013 @ 16:50:37

In a new post to his site Hannes Magnusson talks some about the current PHP documentation (and PHP.net site) formatting and how, while changes to it are quick, they should be instant. He suggests a path to get there and a new tool that could help.

Since 2008 there have been numerous efforts to create a new design for www.php.net, all of which have failed - so far. We've never come as close as two years ago, when the "beta mode" option was added to our website, but we never really got around to finish it. The "beta design" has even received a lot of makeover compared to what is "beta mode" now. To make things a little bit more awesome, there is also a new branch called "responsive" which has a lot of changes in it too, especially for manual pages. Hopefully, one day, we'll actually finish one of these and flip the switch forever.

While he's been a fan of the DocBook structure that's currently in use, he points out that learning the markup can be a hinderance to people contributing. His tool, PhD, does some custom parsing too adding additional complexity. To help, he's working on a new tool (WTFM) to use Markdown formatting instead of DocBook, a more common format.

tagged: phpnet website design docbook markdown update

Link: http://bjori.blogspot.com/2013/09/new-phpnet-designs-floating-around.html


Trending Topics: