code16/sharp
Code-driven CMS framework for Laravel (PHP 8.3+/Laravel 11+). Build admin/CMS sections with a clean UI and strong DX: CRUD with validation, search/sort/filter, bulk or custom commands, and authorization—no front-end code required, data-agnostic.
This is true for every update: be sure to grab the latest assets and to clear the view cache:
php artisan vendor:publish --provider="Code16\Sharp\SharpServiceProvider" --tag=assets
php artisan view:clear
::: tip Information
Due to the migration to Vite, all .js, .css files moved from
/public/vendor/sharp to /public/vendor/sharp/assets.
:::
Show::delete($id), remove Form::delete($id)In Sharp 8 we decided to finally move the instance deletion (meaning the Delete command) where it belongs: in the Show Page and the Entity List, and not in the Form as it was before for legacy reasons. This implies that a new Delete command is added in each instance of the Entity List and in the Show Page (of course, depending on authorizations).
This means that the Form delete($id) method is deprecated in v8 (and will be removed in 9.x), which may impact your code in two ways, depending on your situation:
delete($id) method — it should be in most cases a copy / paste of the Form delete($id). In this case, you should remove entirely the Form delete($id) method.Form::delete() method as a workaround; the right way though (required in 9.x) would be to move the delete() method to your Entity List implementation.For custom delete confirmations, you should call the new SharpShow::configureDeleteConfirmationText(string $confirmationText) and SharpEntityList::configureDelete(?bool $hide = false, ?string $confirmationText = null).
Note: the (undocumented) deleteSharpShow() test assertion was also removed, use deleteSharpEntityList() or deleteSharpShow() instead.
Methods that were deprecated in 7.x were removed entirely. This includes:
sharp.php config file (use SharpMenu and SharpEntity classes instead)Code16\Sharp\Auth\SharpEntityPolicy (see Entity policies)$collapsible param of ShowLayout::addEntityListSection (pass a boolean)SharpFormUploadField::setCroppable() replaced with SharpFormUploadField::setTransformable() (see Upload documentation)It's not a breaking change but minimal requirements are now these.
SharpEntityList's buildListFields(), buildListLayout() and buildListLayoutForSmallScreens() are now deprecated, in favor of an easier way to build the layout in a new buildList() method.
This means we can replace this code from 7.x:
class PostList extends SharpEntityList
{
protected function buildListFields(EntityListFieldsContainer $fieldsContainer): void
{
$fieldsContainer
->addField(
EntityListField::make('cover'),
)
->addField(
EntityListField::make('title')
->setLabel('Title'),
)
->addField(
EntityListField::make('author:name')
->setLabel('Author')
->setSortable(),
)
->addField(
EntityListField::make('published_at')
->setLabel('Published at')
->setSortable(),
);
}
protected function buildListLayout(EntityListFieldsLayout $fieldsLayout): void
{
$fieldsLayout
->addColumn('cover', 1)
->addColumn('title', 4)
->addColumn('author:name', 3)
->addColumn('published_at', 4);
}
protected function buildListLayoutForSmallScreens(EntityListFieldsLayout $fieldsLayout): void
{
$fieldsLayout
->addColumn('title', 6)
->addColumn('published_at', 6);
}
// ...
}
With this in 8.x:
class PostList extends SharpEntityList
{
protected function buildList(EntityListFieldsContainer $fields): void
{
$fields
->addField(
EntityListField::make('cover')
->setWidth(1)
->hideOnSmallScreens(),
)
->addField(
EntityListField::make('title')
->setLabel('Title')
->setWidth(4)
->setWidthOnSmallScreens(6),
)
->addField(
EntityListField::make('author:name')
->setLabel('Author')
->setWidth(3)
->hideOnSmallScreens()
->setSortable(),
)
->addField(
EntityListField::make('published_at')
->setLabel('Published at')
->setWidth(4)
->setWidthOnSmallScreens(6)
->setSortable(),
);
}
// ...
}
The old API is still supported to avoid breaking changes, but is deprecated and will be removed in 9.x. This new format is the only one documented in 8.x, here: Building EntityList.
Sharp now uses the middleware key in the sharp.php config file to declare the middleware to be applied to all routes. In the unlikely case that you were injecting / replacing a middleware, you should now update this config key.
How can I help you explore Laravel packages today?