承接 agri/departments 相关项目开发

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

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

agri/departments

Composer 安装命令:

composer require agri/departments

包简介

Sync departments from the AgriServ central system to your Laravel application

README 文档

README

Receive and sync department updates from the AgriServ central system into your Laravel application.

Requirements

  • PHP 8.2+
  • Laravel 11+

Installation

composer require agri/departments

Publish the config file:

php artisan vendor:publish --tag=departments-config

Add the secret key to your .env:

SSO_SECRET_KEY=your-secret-key

How It Works

Once installed, the package registers a single endpoint:

POST /api/departments/sync

The central AgriServ system calls this endpoint whenever a department's manager_id changes, passing the department key and the new manager_id.

Request:

POST /api/departments/sync
X-Token: your-secret-key

{
    "key": "finance",
    "manager_id": "098765"
}

Responses:

Status Meaning
200 Department updated successfully
401 Invalid or missing X-Token
404 Department key not found
422 Validation failed

Handling the Sync

The package does not manage your database. You are responsible for updating the department by extending the base controller.

1. Create your controller:

<?php

namespace App\Http\Controllers;

use Agri\Departments\Http\Controllers\DepartmentSyncController as BaseController;
use App\Models\Department;

class DepartmentSyncController extends BaseController
{
    protected function sync(string $key, string $managerId): bool
    {
        return (bool) Department::where('key', $key)->update(['manager_id' => $managerId]);
    }
}

2. Point to it in config/departments.php:

'controller' => App\Http\Controllers\DepartmentSyncController::class,

You can also override __invoke() entirely if you need to customize the response or add extra logic.

Configuration

// config/departments.php

return [
    // The secret key sent by the central system in the X-Token header.
    'secret_token' => env('SSO_SECRET_KEY'),

    // The controller that handles the sync request.
    'controller' => \Agri\Departments\Http\Controllers\DepartmentSyncController::class,
];

License

MIT

agri/departments 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-15