Skip to main content
Tutorial Free

Laravel 11: New Artisan "make:trait" Command

March 15, 2024
1 min read

Laravel 11 introduced new Artisan commands. Let's look at the make:trait command in this post.

As with every Artisan command, you can pass the file name to create or leave empty, and Laravel will ask.

make trait command

Here is how the generated interface looks like:

app/Traits/Sluggable.php:

namespace App\Traits;
 
trait Sluggable
{
//
}

As with every generated file, the interface also has stubs so that you can modify them to your needs. After publishing the subs, you can find stubs/trait.stub.

<?php
 
namespace {{ namespace }};
 
trait {{ class }}
{
//
}

The make:trait Artisan command has additional options, which you can check by adding the --help option.

make trait command help

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Comments & Discussion

M
Majd ✓ Link copied!

I think you meant The make:trait instead of The make:enum

N
Nerijus ✓ Link copied!

Thanks for the notice

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.