Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

El_Matella's avatar

Problem installing cviebrock/eloquent-sluggable

Hello everybody, I'm new in the Laravel environment and I am trying to install my firsts composers packages. This is actually my first try, after the Illuminate/Html totally guided installation and I am so disappointed not to succeed by myself..

Anyway, maybe one of you may help me :) The package is this one: https://github.com/cviebrock/eloquent-sluggable

I am running the following command:

$ composer require cviebrock/eloquent-sluggable

But I keep getting an error. I am running Laravel 5, as mentionned on the github repository. Here is the complete error code:

$ composer require cviebrock/eloquent-sluggable
Using version ~2.0 for cviebrock/eloquent-sluggable
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove laravel/framework v5.0.6
    - cviebrock/eloquent-sluggable 2.0.0 requires illuminate/support 4.* -> satisfiable by illuminate/support[v4.0.0, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - cviebrock/eloquent-sluggable 2.0.1 requires illuminate/support 4.* -> satisfiable by illuminate/support[v4.0.0, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - cviebrock/eloquent-sluggable 2.0.2 requires illuminate/support 4.* -> satisfiable by illuminate/support[v4.0.0, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - cviebrock/eloquent-sluggable 2.0.3 requires illuminate/support 4.* -> satisfiable by illuminate/support[v4.0.0, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - cviebrock/eloquent-sluggable 2.0.4 requires illuminate/support 4.* -> satisfiable by illuminate/support[v4.0.0, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - cviebrock/eloquent-sluggable 2.0.5 requires illuminate/support 4.* -> satisfiable by illuminate/support[v4.0.0, v4.0.1, v4.0.10, v4.0.2, v4.0.3, v4.0.4, v4.0.5, v4.0.6, v4.0.7, v4.0.8, v4.0.9, v4.1.0, v4.1.1, v4.1.10, v4.1.11, v4.1.12, v4.1.13, v4.1.14, v4.1.15, v4.1.16, v4.1.17, v4.1.18, v4.1.19, v4.1.2, v4.1.20, v4.1.21, v4.1.22, v4.1.23, v4.1.24, v4.1.25, v4.1.26, v4.1.27, v4.1.28, v4.1.29, v4.1.3, v4.1.30, v4.1.4, v4.1.5, v4.1.6, v4.1.7, v4.1.8, v4.1.9, v4.2.1, v4.2.12, v4.2.16, v4.2.17, v4.2.2, v4.2.3, v4.2.4, v4.2.5, v4.2.6, v4.2.7, v4.2.8, v4.2.9].
    - don't install illuminate/support v4.0.0|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.1|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.10|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.2|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.3|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.4|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.5|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.6|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.7|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.8|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.0.9|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.0|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.1|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.10|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.11|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.12|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.13|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.14|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.15|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.16|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.17|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.18|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.19|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.2|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.20|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.21|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.22|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.23|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.24|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.25|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.26|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.27|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.28|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.29|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.3|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.30|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.4|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.5|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.6|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.7|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.8|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.1.9|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.1|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.12|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.16|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.17|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.2|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.3|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.4|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.5|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.6|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.7|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.8|don't install laravel/framework v5.0.6
    - don't install illuminate/support v4.2.9|don't install laravel/framework v5.0.6
    - Installation request for laravel/framework == 5.0.6.0 -> satisfiable by laravel/framework[v5.0.6].
    - Installation request for cviebrock/eloquent-sluggable ~2.0 -> satisfiable by cviebrock/eloquent-sluggable[2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5].


Installation failed, reverting ./composer.json to its original content.

I don't know where to begin to look at, it would be very nice from you to guide me in order to resolve this issue,

thank you very much for your answers!

0 likes
11 replies
El_Matella's avatar
El_Matella
OP
Best Answer
Level 5

The problem was that I wasn't using the right version, so I added this line to my composer.json and it worked:

"cviebrock/eloquent-sluggable": "3.0.0-alpha"

2 likes
willvincent's avatar

You could use dev-master too. "cviebrock/eloquent-sluggable": "dev-master"

3 likes
blomdahldaniel's avatar

But how do you get "php artisan sluggable:table tablename" to work? I only get this error:

[ErrorException] file_put_contents(/home/luke/Desktop/learninglaravel/app/database/migrations/2015_03_06_174711_add_sluggable_columns.php): failed to open stream: No such file or directory

It seems like the command tires to write to the old laravel 4 structure? Because now /database is not inside app/

So tried to go pass this and created the path, app/database/migrations And i got the migrationfiles but they were empty inside the eloquent stuff. And i got this error aswell: [ErrorException] file_put_contents(/home/luke/Desktop/learninglaravel/app/database/migrations/2015_03_06_174711_add_sluggable_columns.php): failed to open stream: No such file or directory

Have you salved this?

I also have the 3.0.0-alpha

El_Matella's avatar

Hi, no I decided to make my own solution to handle slugs, here is what I made, I don't know if it's part of good practices or not, maybe you could tell me:

public function up()
{
    Schema::create('articles', function(Blueprint $table)
    {
        $table->increments('id');
        $table->string('title');
        $table->text('content');
        $table->string('slug')->unique();
        $table->timestamps();
    });
}

This is an example of migration, so I just added the slug field. Next, the store() method in ArticlesController:

public function store(Request $request)
{
    $article = new Article($request->all());
    $article->slug = $request->title;
    $article->save();
    return redirect('articles');
}

And I used this in the Model to assign the slug:

public function setSlugAttribute($value)
{
    $temp = str_slug($this->title, '-');
    if(!Article::all()->where('slug',$temp)->isEmpty()){
        $i = 1;
        $newslug = $temp . '-' . $i;
        while(!Article::all()->where('slug',$newurl)->isEmpty()){
            $i++;
            $newslug = $temp . '-' . $i;
        }
        $temp =  $newslug;
    }
    $this->attributes['slug'] = $temp;
}

This works well for me, don't hesitate to ask me if you want more information on it

EDIT: Ho yes, and then I used model binding in RoutesServiceProvider like that:

public function boot(Router $router)
{
    parent::boot($router);
    Route::bind('articles', function($value)
    {
        return Article::where('slug', $value)->first();
    });
}

So now I can use Article type parameter in my ArticlesController method:

public function show(Article $article)
{
    return view('articles.show',compact('article'));
}
blomdahldaniel's avatar

Thanks man! I am a rookie in Laravel aswell so this looks great. So you didnt end up using Sluggable? So the str_slug() method is standard in Laravel like the Str::slug() method?

But one thing, as far as I understand, your articles allways get a number behind the article name in the slug? So even the first article is called title:"New Article" it gets a slug of "new-article-1" ?

Maybe that is something i would change, only set the unique numbers when needed. So that most of the article doesnt get a number in their url?

Well done cracking it though, I am still a bit scared of modal bindings and stuff but you seem to have done it all in a nice laravel fassion. But maybe you should extract your uniqe setSlug stuff (like the if and where) to a readable method to get the code just a little more simple.

Thanks for the quick reply btw. :)

El_Matella's avatar

Hey, thank you for the feedback!

No, I didn't use Sluggable, I ended up with too many troubles... And I thought that make my own solution was also good to practice a little.. And yes I think that str_slug is just a class helper for Str::slug(): http://laravel.com/docs/5.0/helpers

In fact, the number is added only if an article already exists. Because in the first place, $temp is just taking the value of the str_slug() method. And the number is added only if "Article::all()->where('slug',$temp)->isEmpty()" is false.

What should I understand by a "readable method", I am not familiar with this therm...

blomdahldaniel's avatar

Yeah thats right, sorry for reading your code wrong. That is nice!

What I meant by "readable method" is that you maybe can set your value in the modal like: $this->attributes['slug'] = generateUniqueSlug($this->title); And then do the logic outside of the setSlugAttribute just to make it clean and simple inside the model. So by "readable method" i mean, extract the code to a method with an readable name, then perform the logic in that method. So the method can be placed either further down in your modal or in a separate class.

BUT i understand that you did not do it in here, in the forum, since your goal was to explain your solution. And that you did very well. So no hard feelings. I just wanted to give my thinking of how you could improve and "beautify" your code even more. so what I mean could make it more simple:

//this would make your setSlugAttribute method easy to understand when you look at it = "read-able"
//so when you look at it quick, you understand what it does in a glance.
//this is extracting your code
public function setSlugAttribute($value)
{
        $this->attributes['slug'] = generateUniqueSlug($this->title);
}

And then have a private method somewhere else:

private function generateUniqueSlug($title)
{
    //and here you put all your logic that solve the problem
        $temp = str_slug($title, '-');
        if(!Article::all()->where('slug',$temp)->isEmpty()){
        $i = 1;
        $newslug = $temp . '-' . $i;
        while(!Article::all()->where('slug',$newurl)->isEmpty()){
            $i++;
            $newslug = $temp . '-' . $i;
        }
        $temp =  $newslug;
    }
    return $temp;
}

So again, your solution is good. I just wanted to give you a tip on how you could make your code more extracted and easy to read and understand. :)

El_Matella's avatar

Yeah, that seems really nicer! Thank you very much for sharing! I will implemant it as soon as I get the time! Thank you so much!

krish8723's avatar

run the following command with sluggable version mention $ composer require cviebrock/eloquent-sluggable:^4.0 instead of $ composer require cviebrock/eloquent-sluggable

Please or to participate in this conversation.