承接 altostrat/tools 相关项目开发

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

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

altostrat/tools

Composer 安装命令:

composer require altostrat/tools

包简介

Tooling for Laravel microservices

README 文档

README

Installation

composer require altostrat/altostrat

Environment Variables

Add the following environment variables to your .env file:

AUTH0_CLIENT_ID=
AUTH0_COOKIE_SECRET=
API_PREFIX=

AUTH0_CLIENT_ID should be the client ID of the Altostrat Auth0 tenant application. AUTH0_COOKIE_SECRET should be a random string of at least 32 characters. API_PREFIX should be the prefix for your API routes, e.g. v1/my-service.

Installation Command

Run the following command run through some boilerplate installation steps:

php artisan altostrat:install

Afterward run the following command to verify that everything is working:

php artisan altostrat:check

Usage

Authenticated routes

Whenever you want to register a route that requires authentication, add it to the routes/authenticated.php file. This will require the user to be authenticated and have the correct scopes to access the route.

During the installation a model called Customer was created. You can use this model to create relationships with your own models. The Customer model is read-only and only acts as a way to leverage eloquent relationships.

Billable Models

When creating a billable service, commonly a particular model is used to represent the billable item. If you want to make a model billable, simply extend the model from Altostrat\Billable\BillableModel.

namespace App\Models;

use Altostrat\Billable\BillableModel;
use Illuminate\Database\Eloquent\Concerns\HasUuids;

class MyModel extends BillableModel
{
    use HasUuids;
    
    protected $fillable = [
        'customer_id',
    ];
    
    //
}

The model that you wish to make billable must have a UUID customer_id column and the id column must be a UUID.

Nothing more is needed, when a user attempts to create an item, a check will be performed to see if the user has a valid subscription. If the user is not allowed to create the item, execution will be halted and a response will be returned to the user.

WARNING: When making a model billable, only an authenticated user can create the model. That means it must come in through an authenticated route and the auth()->user() must be set. You cannot create a billable model through a job or a command.

HTTP requests only.

Helpers

The following helpers are available:

  • new ipv4Address(string $address) - Creates a new IPv4Address object - use the ->withIsp() method to get the ISP name.
  • IpLookup::info(string $address) - Returns an array with information about the IP address.
  • Websocket::push(string $userId, string $event, array $data) - Pushes an event to the user's websocket connection.
  • GeographicHelper::class - Helper class for geographic items, like a list of currencies, countries, etc.

Implementation Notes

Remember to ask the infrastructure team to add the prefix to the ALB with these paths:

  • v1/my-service/*
  • v1/my-service

Service Count Routes

Billable models are automatically made countable.

As an example, if you set the prefix to v1/my-service, the following route will be available:

GET /v1/my-service/billable-count/{model}

The model parameter is the name of the model, e.g. my-model. Model names should be converted to kebab-case. E.g. MyModel becomes my-model.

You may optionally pass the count=1 URL parameter to get the count of the model.

If count=1 is not passed, the route will return a list like this:

[
    {
        "id": "....", // The ID of the model
        "site_id": "...." // Only if the model has a site_id column otherwise this will be null
    }
]

If count=1 is passed, the route will return a count like this:

{
    "count": 1
}

altostrat/tools 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-01-07