Laravel Package Development
What are we building? We are talking about our plan, approach and some of the reasons for a Package approach. We will also touch up on prerequisites for this video series.
Let's Get Started
We are starting from scratch, pulling in the required testing package and setting up composer with PSR4 autoloading and PHPUnit.
Let's get familiar with the basics of markdown, we will be using markdown to write prettier blog posts for our project. You may skip this lesson if you are familiar already.
We are experimenting with the parsedown PHP library and extracting a MarkdownParser class we will be using later on during our processing step.
Press File Structure
We are going to have a special format for our blog posts, so we are tackling the regular expression in this segment to make that work for our project. We will wrap it up with a parser class and tests.
Let's tackle the body part of our press file and make sure that it gets properly returned in our data array.
The Date Field
It's time for us to tackle a special field, in this first implementation, the date field will need to be properly parsed into a Carbon object.
Refactoring to Classes
Our previous implementation clearly had some flaws, so let's refactor to classes now to have more flexibility for any number of fields we would add.
The Extra Field
Let's take care of any additional fields that get passed in by appending them to a JSON string in an additional column we'll call, Extra.
The Base Service Provider
Let's introduce a new concept, Package Service Providers. In this lesson, we focus on the function of a service provider and we end by adding a base provider.
Register Service Provider in Tests
Now that we have our Service Provider, let's hook it up to our package test suite.
In-Memory Testing Database
Now that we have a base TestCase, it's time to setup an In-Memory SQLite Testing Database.
Models & Factories
Models and Factories are integral in any Laravel application, in this lesson we introduce a Post model and a factory to quickly generate testing data.
Package Auto Discovery
In this episode, we are leveraging one of Laravel's latest features, Package Auto Discovery. Let's work together to have our package connect to any Laravel application automatically.
We've reached the point in our package where we are needing a console command, let's add one in this lesson.
Building The Process Command
Follow along as we continue to work on our process command. We will create a simple implementation of the command to get it working.
It's time to start our refactor line by line, starting with a config file and publishable assets for our package.
File Driver Part 1
In Part 1, we begin working towards a driver-based approach for our package in which we are able to select where and how our markdown files are stored.
File Driver Part 2 (Refactoring to an Abstract Class)
In this episode, we refactor an abstract class out of our FileDriver class to facilitate future driver development and restructure our config file to accommodate driver-specific config options.
Adding Routes, Views & Controllers
In this lesson we add views, routes and a controller to our package. We also make a route prefix customizable and add a namespace to our Route group.
Creating a Press Class Facade (Binding a Singleton)
In this lesson, we start by binding a singleton of our Press class and then add a Facade for it. Then, we refactor our code base to use this new Press Facade.
Post Repository (Refactoring to a Repository)
To complete the ProcessCommand class, we are going to extract the logic to save a post to it's own class using the repository pattern. We will complete the lesson by giving the user better feedback on what the command has done.
Allowing for Package Expansion Part 1
In this 3 part series, we refactoring our implementation of fields to allow a package user to expand our fields with their own custom fields. In part 1, we taking care of the extra column field and make sure that is saving all of necessary information from the post array.
Allowing for Package Expansion Part 2
In this 3 part series, we refactoring our implementation of fields to allow a package user to expand our fields with their own custom fields. In part 2, we are explicitly registering our default fields using our PressBaseServiceProvider.