Laravel 11: New Artisan "make:trait" Command

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

avatar

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

avatar

Thanks for the notice

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 68 courses (1183 lessons, total 43 h 18 min)
  • 90 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord

Recent New Courses