Sharp for Laravel: version 5 is out today.

Let’s review some real world projects in this post.

Philippe Lonchampt
code16
4 min readSep 4, 2020

--

It’s been a long time since my last post on Sharp (okay, since my last post on anything). But today is a good one to change that: we just released Sharp 5.

Three statements first:

  • if you were already using a previous Sharp 5.0 alpha or beta version, this simply is a regularization: everything should be fine. And to be honest, at Code 16, we were using 5.0 beta versions in production for weeks (okay, months).
  • If you are using Sharp 4.2.x, migration will be, unlike this big 5.0 may look, really easy.
  • If you are not familiar with Sharp for Laravel, this blog post might not be a good place to start, but live dangerously and stay with me before going to the documentation website which is, you know… a documentation website.

Then, let’s talk about versioning. After years of nonsense, and to follow the wave in the Laravel community, we decided to move to semantic versioning. This means all 5.x coming versions will be safe from breaking changes, and that the next major version will be 6.0. And finally, we drop Laravel 5.x compatibility: Sharp supports 6+.

So, what’s new? Like the release notes will tell you, not much on the paper: a big front code refactoring, some back code optimizations / rewriting, and some solid improvements on the Show Page feature brought by the 4.2 version. But since I think it’s a big deal (I mean: this whole Show Page feature thing), I would like present here some real world examples.

But first, a non real world example of a Show Page

(The real one are coming after, I promise)

This is a Show Page extracted from Saturn, the Sharp dummy example project which is available as a demo.

In this example we can see the general UI improvements, as well as the new fields:

  • the File field, here images with thumbnails, which presents the file and allows the administrator to directly download it,
  • and the List field (files are in fact a list of files).
  • There is even a third new one: the spaceship name, McClure (I should probably enhance my seeder…), is a really simple custom SharpShowField.

The rest should not be new, but this page features a sub entityList (pilots) with filters, search, direct creation and custom dedicated entity and instance commands; a long collapsible text field and some regular text fields, organized in sections; global commands and a state indicator.

As stated before, Saturn is the Sharp demo project we use for prototyping and development; if you want to play with it for real, it’s here: https://sharp.code16.fr/sharp/login.

So now let’s see two real projects.

Manage applications with a simple validation workflow

We want in this project to allow administrators to review applications for a dedicated online directory; to be accepted, the applicant needs approval from two different services. Here’s the full Show Page in Sharp:

The first two sections contains the applicant data.

The third one (“Candidature”) allows the administrator to directly download and see the documents attached to the application, taking advantage of both List and File fields.

And the last one is a sub EntityList where administrators can enter their reviews. With some regular Sharp authorizations and the leverage of multi-forms and filters, it’s easy to add a review, keeping all of them but only displaying the “current one” (with a filter), meaning the last one of each service.

Display and handle an e-commerce order

In the context of an e-commerce order, we developed a much more complicated Show Page:

The first section features some custom fields (a barcode, a state-with-icon label). Sections 2 and 3 are general customer and store data (in a marketplace context).

Section 4 is the actual order rows, presented in a sub EntityList; each row is clickable to access the product page (since Show Page can be piled up).

Section 5 allows the store owner to answer to the customer (who can send messages in his account, on the public website), and to see the whole discussion.

And the last section is only displayed to the marketplace administrator: this is a list of all order events, to be able to really understand the order current status.

With all this plus commands to handle the order (accept, cancel, export, …), Sharp allowed us to create a really useful order management system.

What’s next?

For Sharp, we plan to work on dashboards (UI and graph panels), and to refactor and improve some Form fields. We don’t have any 6.x plans at the moment, but I’m sure we will find something.

And for the next post blog, I’m not sure… I’m tired of “how to” posts! Maybe I can develop a bit this “real world Sharp” series, since we have a lot of production projects which use Sharp? Let me know what you think of that on twitter.

--

--

Philippe Lonchampt
code16
Editor for

Developer and founder of Code 16, maintainer of Laravel Sharp.