承接 visiarch/laravel-trait 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

visiarch/laravel-trait

最新稳定版本:1.0.0

Composer 安装命令:

composer require visiarch/laravel-trait

包简介

A simple Laravel package to create traits, using artisan commands

README 文档

README

laravel Trait

laravel-trait

Latest Stable Version License

"Buy Me A Coffee"

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 ?

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

composer require visiarch/laravel-trait

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

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

Create a php trait

/app/Traits/Loggable.php

$ php artisan make:trait Loggable

/app/Traits/Loggable.php

<?php

namespace App\Traits;

/**
 * Trait Loggable
 * @package App\Traits
 */

trait Loggable {
    // write your code here
}

Implementation

<?php
trait Loggable {
    public function log($message) {
        return $message;
    }
}

class User {
    use Loggable;
}

class Order {
    use Loggable;
}

$user = new User();
$user->log('User created');

$order = new Order();
$order->log('Order placed');

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

How can I thank you?

Why not star the github repo? I'd love the attention! Why not share the link for this repository on any social media? Spread the word!

Thanks! visiarch

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-28