Yes, it is true that the package laravelcollective/html is abandoned and it is recommended to use spatie/laravel-html instead. Spatie/laravel-html is a package that provides similar functionality to laravelcollective/html. It can be used to generate HTML forms and links, as well as other HTML elements.
To use spatie/laravel-html, you can follow these steps:
- Install the package using composer:
composer require spatie/laravel-html
- Add the service provider to your config/app.php file:
'providers' => [
// ...
Spatie\Html\HtmlServiceProvider::class,
],
- Add the facade to your config/app.php file:
'aliases' => [
// ...
'Html' => Spatie\Html\Facades\Html::class,
],
- You can now use the Html facade to generate HTML elements in your views:
{!! Html::link('route.name', 'Link Text', ['class' => 'link-class']) !!}
This will generate an HTML link with the specified route name, link text, and CSS class.
Similarly, you can use the Form facade to generate HTML forms:
{!! Form::open(['route' => 'route.name']) !!}
{!! Form::text('name', null, ['class' => 'form-control']) !!}
{!! Form::submit('Submit', ['class' => 'btn btn-primary']) !!}
{!! Form::close() !!}
This will generate an HTML form with a text input field and a submit button.
Overall, spatie/laravel-html provides similar functionality to laravelcollective/html and can be used as a replacement.