Download the PHP package whitecube/laravel-sluggable without Composer

On this page you can find all versions of the php package whitecube/laravel-sluggable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-sluggable

Laravel Sluggable

A trait to use on your models to generate slugs based on another attribute's value. Supports translated attributes (using spatie/laravel-translatable).

Installation

You can install the package via composer:

Usage

Changing the slug storage attribute

By default, the slug is configured to be stored in an attribute named slug. You can overwrite this setting with the public $slugStorageAttribute property on your model.

Conditional sluggable attributes

If needed, you can overwrite the trait's getSluggable() method and put your own sluggable attribute choice logic in it:

Translated slugs

You can generate slugs based on translated attributes (using spatie/laravel-translatable). Remember to add the slug attribute to the public $translatable array to easily access them.

Route Model Binding

Be advised that this package overrides the getRouteKeyName method, which means Laravel's Route Model Binding will use the slug attribute by default (or the $slugStorageAttribute you have defined). In most cases, this is great, saves you a step and cleans up your models, but if you must, you can change it to whatever you like.

When using Route Model Binding, some other interesting features become available.

Custom Route Model Binding Query

Sometimes you'd want to add custom behavior to the query Laravel performs. This packages makes it possible to hook into the query by defining a getRouteBindingQuery method on the model, which could be useful in several cases such as including soft-deleted results :

Cross-language redirects

If the slug provided in the URL does not correspond to the current locale's slug translation, but corresponds to a slug in another language, this package can automatically redirect to the proper slug.

An example: given the above example's post, we could imagine the following routing configuration:

But if we visit /fr/articles/the-title, the package will automatically perform a 301 redirect to /fr/articles/le-titre.

This behavior can be disabled by setting public $slugTranslationRedirect = false; on your model, in which case visiting /fr/articles/the-title will just render a 404 page.

Translated URL generator

Do you need to generate alternate locale links for a translated sluggable model? We've got you covered. Take a look at getSluggedUrlForRoute($route, $locale, $fullUrl):

Considering the current route being /blog/{post}/{tab} with request parameter {tab} = 'comments', the result would be:

💖 Sponsorships

If you are reliant on this package in your production applications, consider sponsoring us! It is the best way to help us keep doing what we love to do: making great open source software.

Contributing

Feel free to suggest changes, ask for new features or fix bugs yourself. We're sure there are still a lot of improvements that could be made, and we would be very happy to merge useful pull requests.

Thanks!

Made with ❤️ for open source

At Whitecube we use a lot of open source software as part of our daily work. So when we have an opportunity to give something back, we're super excited!

We hope you will enjoy this small contribution from us and would love to Twitter for more updates!


All versions of laravel-sluggable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0|^9.0
illuminate/support Version ^9.0|^10.0|^11.0
laravel/helpers Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package whitecube/laravel-sluggable contains the following files

Loading the files please wait ....