Skip to content

Upgrading from 9.x to 10.x

The upgrade command

Sharp 10 comes with an upgrade command that replaces and notifies for deprecated and removed code. You can run it with

bash
php artisan sharp:upgrade app/Sharp

Where app/Sharp is the path of your sharp code.

Updating Dependencies

If you depend on them, you should update the following dependencies in your composer.json file :

Deprecated methods

Forms

Upload setImageCompactThumbnail() has no impact and can be removed:

php
\Code16\Sharp\Form\Fields\SharpFormUploadField::make('upload')
  ->setImageCompactThumbnail() 

Testing

The legacy testing API is deprecated and will be removed in 11.x. Please refer to (cf. Testing). Here are replacement examples:

php
uses(\Code16\Sharp\Utils\Testing\SharpAssertions::class)

it('test', function () {
    $this->callSharpEntityCommandFromList(PersonEntity::class, MyCommand::class, ['attr' => 'some_value']) 
    $this->sharpList(PersonEntity::class)->entityCommand(MyCommand::class)->post(['attr' => 'some_value']) 
    
    $this->callSharpInstanceCommandFromList(PersonEntity::class, 1, MyCommand::class, ['attr' => 'some_value']) 
    $this->sharpList(PersonEntity::class)->instanceCommand(MyCommand::class, 1)->post(['attr' => 'some_value']) 
    
    $this->callSharpInstanceCommandFromShow(PersonEntity::class, 1, MyCommand::class, ['attr' => 'some_value']) 
    $this->sharpShow(PersonEntity::class, 1)->instanceCommand(MyCommand::class)->post(['attr' => 'some_value']) 
    
    $this->getSharpShow(PersonEntity::class, 1) 
    $this->sharpShow(PersonEntity::class, 1)->get() 
    
    $this->getSharpForm(PersonEntity::class, 1) 
    $this->sharpForm(PersonEntity::class, 1)->get() 
    
    $this->getSingleSharpForm(PersonEntity::class) 
    $this->sharpForm(PersonEntity::class)->get() 
    
    $this->updateSharpForm(PersonEntity::class, 1, []) 
    $this->sharpForm(PersonEntity::class, 1)->update([]) 
    
    $this->storeSharpForm(PersonEntity::class, 1, []) 
    $this->sharpForm(PersonEntity::class, 1)->store([]) 
    
    $this->updateSingleSharpForm(PersonEntity::class, []) 
    $this->sharpForm(PersonEntity::class)->update([]) 
    
    $this->withSharpBreadcrumb(function (\Code16\Sharp\Utils\Links\BreadcrumbBuilder $builder) { 
        $builder->appendEntityList(PersonEntity::class)->appendShowPage(PersonEntity::class, 1) 
    })->getSharpForm(PersonEntity::class, 1) 
    $this->sharpList(PersonEntity::class)->sharpShow(PersonEntity::class, 1)->sharpForm(PersonEntity::class)->get() 
})

Removed classes and methods

Several features and methods that were deprecated in Sharp 9.0 have been removed to clean up the codebase.

General

  • The currentSharpRequest() helper and its associated CurrentSharpRequest class were removed. Use sharp()-⁠>context() instead (cf. Context).
  • The SharpAuthenticationCheckHandler interface was removed. Use the viewSharp Gate instead.
  • The withSharpCurrentBreadcrumb() method in SharpAssertions was removed. Use withSharpBreadcrumb() instead.
  • Removal of "multi-forms". Replace all SharpEntity::getMultiforms() implementations to SharpEntityList::configureEntityMap() instead (cf. Building entity list).
  • Smart handling of legacy fontaweome icons class has been removed. Tou must convert all fa- occurences to fas-*, far-*, fab-*.

Configuration

  • The legacy configuration handling based on the sharp.php config file was removed. You must now use a SharpAppServiceProvider with a SharpConfigBuilder.
  • SharpConfigBuilder::addEntity() has been removed in favor of SharpConfigBuilder::declareEntity().

Forms

  • The legacy $formValidatorClass property handling in SharpForm was removed. Implement the SharpForm::rules() and SharpForm::messages() methods instead (cf. Building form). Along with this removal, the following classes have been removed:
    • \Code16\Sharp\Form\Validator\SharpFormRequest
    • \Code16\Sharp\Form\Validator\SharpValidator
    • \Code16\Sharp\Http\Middleware\Api\BindSharpValidationResolver (remove this from config)
  • In SharpFormUploadField, the following deprecated methods were removed:
php
\Code16\Sharp\Form\Fields\SharpFormUploadField::make('upload')
  ->setCropRatio() 
  ->setImageCropRatio() 
  
  ->shouldOptimizeImage() 
  ->setImageOptimize() 
  
  ->setTransformable() 
  ->setImageTransformable() 
  
  ->setFileFilterImages() 
  ->setImageOnly() 
  
  ->setFileFilter() 
  ->setAllowedExtensions() 
  • The FormLayoutColum::withSingleField() & ShowLayoutColum::withSingleField() method was removed. Use withField() or withListField() instead.
  • SharpFormDateField::setDisplayFormat() has been removed
  • SharpFormAutocompleteField was removed. Migrate to the following
    • SharpFormAutocompleteField::make('key', 'local') to SharpFormAutocompleteLocalField::make('key')
    • SharpFormAutocompleteField::make('key', 'remote') to SharpFormAutocompleteRemoteField::make('key')

Entity Lists

  • The setWidthOnSmallScreens() and setWidthOnSmallScreensFill() methods in EntityListField were removed as they are no longer used in the new front-end table UI.
  • The configureMultiformAttribute() method in SharpEntityList was removed. Use configureEntityMap() instead.

Show

  • The configureMultiformAttribute() method in SharpShow was removed. It's not used by sharp.

Filters

The following classes have been renamed / moved:

php
use \Code16\Sharp\EntityList\Filters\EntityListCheckFilter; 
use \Code16\Sharp\Utils\Filters\CheckFilter; 
use \Code16\Sharp\Filters\CheckFilter; 

use \Code16\Sharp\EntityList\Filters\EntityListDateRangeFilter; 
use \Code16\Sharp\Utils\Filters\DateRangeFilter; 
use \Code16\Sharp\Filters\DateRangeFilter; 

use \Code16\Sharp\EntityList\Filters\EntityListDateRangeRequiredFilter; 
use \Code16\Sharp\Utils\Filters\DateRangeRequiredFilter; 
use \Code16\Sharp\Filters\DateRangeRequiredFilter; 

use \Code16\Sharp\EntityList\Filters\EntityListSelectFilter; 
use \Code16\Sharp\Utils\Filters\SelectFilter; 
use \Code16\Sharp\Filters\SelectFilter; 

use \Code16\Sharp\EntityList\Filters\EntityListSelectMultipleFilter; 
use \Code16\Sharp\Utils\Filters\SelectMultipleFilter; 
use \Code16\Sharp\Filters\SelectMultipleFilter; 

use \Code16\Sharp\EntityList\Filters\EntityListSelectRequiredFilter; 
use \Code16\Sharp\Utils\Filters\SelectRequiredFilter; 
use \Code16\Sharp\Filters\SelectRequiredFilter; 

Released under the MIT License.