定制 envor/platform 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

envor/platform

Composer 安装命令:

composer require envor/platform

包简介

This is my package platform

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Configure your platform

Installation

You can install the package via composer:

composer require envor/platform

You can publish the config file with:

php artisan vendor:publish --tag="platform-config"

This is the contents of the published config file(s):

// config/database.php
return [
        /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once throughout the application.
    |
    */

    'platform' => env('PLATFORM_DB_CONNECTION', 'sqlite'),
    'default' => env('DB_CONNECTION', 'sqlite'),
];

// config/auth.php
return [
    'passwords' => [
        'users' => [
            'provider' => 'users',
            'table' => 'password_reset_tokens',
            'connection' => env('PLATFORM_DB_CONNECTION', 'sqlite'),
            'expire' => 60,
            'throttle' => 60,
        ],
    ],
];

// config/platform.php

return [
    'landing_page_disk' => env('LANDING_PAGE_DISK', 'public'),
    'profile_photo_disk' => env('PROFILE_PHOTO_DISK', 'public'),
    'stores_contact_info' => env('STORES_CONTACT_INFO', true),
    'empty_logo_path' => 'profile-photos/no_image.jpg',
    'empty_phone' => '(_ _ _) _ _ _- _ _ _ _',
    'empty_fax' => '(_ _ _) _ _ _- _ _ _ _',
    'logo_path' => env('PLATFORM_LOGO_PATH'),
    'name' => env('PLATFORM_NAME'),
    'phone' => env('PLATFORM_PHONE_NUMBER'),
    'fax' => env('PLATFORM_FAX_NUMBER'),
    'street_address' => env('PLATFORM_STREET_ADDRESS'),
    'city_state_zip' => env('PLATFORM_CITY_STATE_ZIP'),
    'email' => env('PLATFORM_EMAIL'),
];

// config/session.php

<?php

return [
    'connection' => env('PLATFORM_DB_CONNECTION'),
];

Usage

Using the platform connection

Add the trait Envor\Platform\UsesPlatformConnection to your model:

class Business extends Model
{
    use \Envor\Platform\UsesPlatformConnection;
}

Using Platform UUID's

Add the uuid column to your model's table in a migration:

$table->uuid('uuid')->index()->unique();

Add the trait Envor\Platform\UsesPlatformUuids to your model:

class Business extends Model
{
    use \Envor\Platform\HasPlatformUuids;
}

Logos

Allows a model to have a logo, which can be updoaded, deleted and replaced by the user.

  1. Add profile_photo_path (string) field to your model's database table
$table->text('profile_photo_path')->nullable();
  1. Add \Envor\Platform\HasProfilePhoto trait to your model.

It can be any model but we will use the user model as an example.

...
class User extends Authenticatable
{
    ...
    use \Envor\Platform\HasProfilePhoto;
    ...
}

Usage example

$user->updateProfilePhoto($request->file('photo'));
<img src="{{ $user->profile_photo_url }}" alt="{{ $user->name }}" class="rounded-full h-20 w-20 object-cover">
  1. Use the form (optional)

Note

Requires livewire/volt and tailwind.

composer require livewire/volt
php artisan volt:install

Now you can add the form to any view:

@livewire('update-logo-form', ['model' => auth()->user()])

Screenshot:

alt text

Landing Pages

Allows a model to have an html "landing page", which can be uploaded, deleted and replaced by the user.

  1. publish and run migration

This will create a landing_pages table where landing page paths and relationship info will be stored.

php artisan vendor:publish --tag='platform-migrations'
php artisan migrate --path=database/migrations/platform
  1. Add \Envor\Platform\HasLandingPage trait to your model.

It can be any model but we will use the user model as an example:

...
class User extends Authenticatable
{
    ...
    use \Envor\Platform\HasLandingPage;
    ...
}

Usage example

$user->updateLandingPage($request->file('landing-page'));
<a href="{{ $user->url }}">Visit Landing Page</a>
  1. Use the form (optional)

Note

Requires livewire/volt and tailwind.

composer require livewire/volt
php artisan volt:install

Now you can add the form to any view:

@livewire('update-landing-page-form', ['model' => auth()->user()])

Screenshot:

alt text

  1. Make The landing page the home page (optional)

In this example we will illustrate how it might be done for a user which has a domain property.

Add domain field to users table in a migration:

$table->string('domain')->nullable();

Then show the page on the home '/' route:

use Illuminate\Http\Request;

Route::get('/', function (Request $request) {

    $user = \App\Models\User::where('domain', $request->getHost())->first();

    if ($user?->landingPage) {
        return response()->file(Storage::disk($user->landingPageDisk())->path($user->landingPagePath()));
    }

    return view('welcome');

})->name('home');

Contact Info

Allows a model to have address and other contact details

  1. Add contact data text (or json) field to your model's database table
$table->text('contact_data')->nullable();
  1. Add \Envor\Platform\HasContactData trait to your model.

It can be any model but we will use the user model as an example:

...
class User extends Authenticatable
{
    ...
    use \Envor\Platform\HasContactData;
    ...
}

Usage example

$user->updateContactData([
    'name' => 'Jane Doe',
    'address' => [
        '1234 somewhere lane'
    ];
]);
  1. Use form (optional)

Note

Requires livewire/volt and tailwind.

composer require livewire/volt
php artisan volt:install

Now you can add the form to any view:

@livewire('update-contact-info-form', ['model' => $user, 'readonly' => $user->id != auth()->id()])

Screenshot:

alt text

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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

envor/platform 适用场景与选型建议

envor/platform 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.66k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「platform」 「envor」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 envor/platform 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 envor/platform 我们能提供哪些服务?
定制开发 / 二次开发

基于 envor/platform 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 6.66k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 4
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-02-09