PHPackages                             visiarch/laravel-trait - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. visiarch/laravel-trait

ActiveLibrary

visiarch/laravel-trait
======================

A simple Laravel package to create traits, using artisan commands

1.0.0(1y ago)0171MITPHP

Since Jun 28Pushed 1y agoCompare

[ Source](https://github.com/visiarch/laravel-trait)[ Packagist](https://packagist.org/packages/visiarch/laravel-trait)[ Docs](https://github.com/visiarch/laravel-trait)[ RSS](/packages/visiarch-laravel-trait/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (1)

[![laravel Trait](https://github.com/visiarch/laravel-trait/raw/main/images/laravel-trait-banner.png)](https://github.com/visiarch/laravel-trait/blob/main/images/laravel-trait-banner.png)

laravel-trait
=============

[](#laravel-trait)

[![Latest Stable Version](https://camo.githubusercontent.com/4b503a05dfef19244aa6284adbba68491d28317e531982e4a6c2b00e5291e1ff/687474703a2f2f706f7365722e707567782e6f72672f76697369617263682f6c61726176656c2d74726169742f76)](https://packagist.org/packages/visiarch/laravel-trait)[![License](https://camo.githubusercontent.com/279e6b4487f0acae967334469836a7efc1d0283a0e919246ef944a278b66dc5c/687474703a2f2f706f7365722e707567782e6f72672f76697369617263682f6c61726176656c2d74726169742f6c6963656e7365)](https://packagist.org/packages/visiarch/laravel-trait)

[!["Buy Me A Coffee"](https://camo.githubusercontent.com/9f44ce2dc3b3eecdd02598900866ffc518801df1932849703dae1e5ce5031070/68747470733a2f2f7777772e6275796d6561636f666665652e636f6d2f6173736574732f696d672f637573746f6d5f696d616765732f6f72616e67655f696d672e706e67)](https://www.buymeacoffee.com/bagussuandana)

> A Simple Package to create traits, using artisan commands in laravel.

This package extends the `make:` commands to help you easily create trait classes in Laravel 9+.

What is Trait ?
===============

[](#what-is-trait-)

Traits are a mechanism in PHP that allows the use of methods across classes. This allows developers to write functions that can be reused in many classes.

Install
=======

[](#install)

```
composer require visiarch/laravel-trait
```

Once it is installed, you can use any of the commands in your terminal.

Usage
=====

[](#usage)

Traits are used to avoid code duplication and facilitate reuse of the same logic across multiple classes without using inheritance.

```
php artisan make:trait {name}
```

Examples
========

[](#examples)

Create a php trait
------------------

[](#create-a-php-trait)

`/app/Traits/Loggable.php`

```
$ php artisan make:trait Loggable
```

`/app/Traits/Loggable.php`

```
