Why I think Sharp for Laravel is đź‘Ť

Alternative title: “How the ocean makes me feel optimistic”

Philippe Lonchampt
code16
5 min readAug 14, 2019

--

The ocean, where decisions are made.

I just got back from vacation; I was, like almost every year, near the ocean. And I thought, looking at the waves, like almost every year: “What can we, at Code 16, build this year?”. But unlike some previous times, I end up thinking that we should not build something new, but rather focus on one of our open source projects, which is Sharp for Laravel.

Sharp is an open source “content management framework” for Laravel, and my intent is not to describe the tool in this post (if you are new, start here). Instead, I would like to share some examples to demonstrate why I think this project, despite inevitable flaws and weaknesses, is a good solution for many admin cases. And as I still feel on vacation, let’s relax and write it as a top 5:

#5 Sharp can manage almost any kind of data

There are various built-in form fields, with many options, and a way to build custom ones. We use Sharp, at Code 16, for websites or apps that handle various data such as theaters seasons, e-commerce products, touristic information, magazine articles, CRM related data, metrics, and much more…

Here’s for instance a form for a “show performance”, in a real project (in french, I’m afraid):

Custom Markdown, images, files, lists, selects, autocompletes, …

Even if this form is quite complex, Sharp does a pretty good job to make it looks understandable, with layout (tabs, sections and columns, which are fully described in the code), or help texts.

List views columns and cells are fully customizable, as this other all-french example from the same project will demonstrate:

From list views, it’s fairly easy to add a custom state handler (useful for content publishing), and a preview action.

Like always in Sharp, implementation of these features is fully on the developer hands.

And I can’t finish this part without mentioning the built-in data localisation, which leaves the data storage strategy totally opened:

#4 Sharp is a good functional admin panel

Sharp has commands, which can be called on a single instance or a search/filtered result set, with optional authorizations, confirmation, specific form, … and can result in a modal message, a full reload, a smart refresh or a file download.

A command with a form (dummy) example, from Saturn, Sharp’s demo project

Lists in Sharp can be filtered and searched, and even reordered.

And dashboards, which are still evolving, can present graphs and linked panels to the user depending on its credentials.

Like other admin tools, the idea is to use Sharp as CMS and admin panel, but unlike many of these tools, I think that Sharp does that in a comprehensive and clean UX.

#3 Sharp is very flexible, but can still reduce pain

A developer can use Sharp as a complete front-end tool and code almost everything as he wishes on the back side. But when using some conventions or standard tools, we can benefit of some useful magic… Two examples of that:

First, CRUD work, as in saving data: if you are leveraging Eloquent, Sharp can do all the work for you with theWithSharpFormEloquentUpdater trait (detailed here), meaning your update / store method for a whole model and it relationships can be as simple as:

Of course, you still have room for specific code here.

And second, uploads, which can be painful. Here’s a detailed post on this topic, but in a few words, with some convention, Sharp will do everything, from file upload to DB storage.

And yes, even image cropping.

#2 Sharp is not invasive, nor demanding

Sharp was built with some ideas in mind:

  • First, do not touch the project code. This means that adding or removing Sharp from a project should not have any effect on the public side, nor on the functional code.
  • Second, do not expect any data structuration. Yes, Sharp is easier to use when combined with Eloquent models (see previous chapter) but it is not a requirement: in a real project, datasources can be multiple (coming from DB, files, API endpoint, …).

#1 Sharp is open, actively developed, and free to use

Sharp is fully open source. We work on the actual v4 since a couple of years, continuously enough and with backward compatibility in mind—we use it in almost all our client projects.

And of course, Sharp is and will stay free, in order to give back a little of what the open source community, and the Laravel one in particular, offers to us.

So what’s next?

First, we will continue to fix or enhance some code parts which need it, looking at them months after. But we also plan for new features:

In a very near future, the next version will include a long-awaited feature, which is date range filters, for lists or dashboards:

The 4.1.17 version with this feature will be tagged very soon, if not already.

Dashboards, precisely, will continue to evolve with better charts and some new widgets (a “list group items with score” is in the pipe to display top ordered products for instance).

And we are finally building a “show” page. For now, Sharp is mostly lists with commands and filters, and forms with fields. We plan to add an optional “show” page between those two, with read only data visualization and instance commands.

That’s it for this post that I intended to keep general, and quick to read; feel free to reach me on twitter to know more about Sharp, and try it starting here.

--

--

Philippe Lonchampt
code16
Editor for

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