Write a Composer Package With Me
If you’d like to come along for the ride, I need to build a small package for Laracasts to handle the loading and processing of a transcripts file. The ultimate goal is to provide a pretty slide-out panel to quickly scan and read the full transcript for a given lesson. Even better, when you click any relevant sentence, it will take you to the exact portion of the video where that line is spoken.
In this series, we’ll use test-driven development to drive the backend PHP portion of this new feature.
Terms, Package Configuration, and the First Test
To get the ball rolling, let’s initalize Composer, pull in PHPUnit, and then prepare the configuration for the project. We’ll then finish up the lesson by writing the first simple test we can think of.
Load the Transcript as an Array
Next up, it would be useful if we could organize the transcript into a list, or array. With that in mind, let’s introduce a new lines() method.
Introduce a Line Object
In this episode, we’ll extract a Line class that can be responsible for all behavior and manipulation that is specifically related to a single line of dialogue.
Render a Transcript as HTML
It might be useful to offer the ability to render the loaded transcript as HTML, including clickable links to each timestamp. Let’s play around with a possible implementation in this video.
Final Squint Test Before Publishing
I think we’re just about ready to push this up to Packagist. But before we do, let’s do one last squint test and perform any lingering refactorings. I think I can see a few places where we might improve the structure of the code.
Tag and Publish to Packagist
I think we’re now ready to tag our first 0.1.0 release. In this lesson, we’ll create a new GitHub repository, push our code up to it, and then add it to Packagist.org.
Prepare a Minor Release
At this point, our package is available to anyone in the world – including me. As I’ve been working with it behind the scenes, I’ve come across a few small snags that need to be ironed out. In this episode, we’ll add a couple small features and then tag a new minor release.
User Reviews
Be the first to review “Write a Composer Package With Me”
You must be logged in to post a review.
There are no reviews yet.