承接 neeraj/catalyst-starterkit-restapi 相关项目开发

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

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

neeraj/catalyst-starterkit-restapi

Composer 安装命令:

composer require neeraj/catalyst-starterkit-restapi

包简介

Laravel Starter Kit with Authentication and CRUD Repository

README 文档

README

A ready-to-use Laravel starter kit featuring authentication and a base CRUD repository. This package is designed to save time and effort by providing a robust foundation for any Laravel-based API application.

Features

Authentication

  • JWT-based authentication for secure API token management.

Base CRUD Repository

  • Centralized CRUD repository pattern to minimize code redundancy and enhance maintainability.

Image Uploads

  • Handles image uploads and storage with automatic naming and folder organization.
  • Supports image uploads for all CRUD features, with files saved according to the model ID.

API Ready

  • Pre-configured routes and controller logic to quickly set up API endpoints.

Flexible Parameters

  • No need to send empty arrays (e.g., []) for parameters unless required.
  • Middleware adjusts functionality based on the presence of data in the parameters.

Installation

Install the package using Composer:

composer require neeraj/catalyst-starterkit-restapi
php artisan jwt:secret
php artisan migrate

Usage

Controllers

  • Example ProductController is provided with full CRUD functionality.
  • Extend the CrudRepository to add logic for other models.
  • Ensure the image folder is updated dynamically using the $folder variable based on model requirements.

Routes

Pre-configured routes for authentication and product management:

// routes/api.php
Route::apiResource('products', ProductController::class);

To update a product using a PUT request:

localhost:8000/api/products/1?_method=PUT

Requests

Custom request classes for validation:

  • StoreProductRequest
  • UpdateProductRequest

Environment Variables

  • Set pagination count with PAGINATE in .env.
  • Modify as per your requirements.

Folder Structure

app/
├── Http/
│   ├── Controllers/
│   │   └── ProductController.php
│   ├── Requests/
│   │   ├── StoreProductRequest.php
│   │   └── UpdateProductRequest.php
├── Models/
│   └── Product.php
├── Repositories/
│   ├── BaseRepository.php
│   └── CrudRepository.php

Image Handling

  • Images are stored in folders named according to the model ID.
  • To allow for multiple images, use the $file array to specify fields for the images.
  • Dynamically change the $folder variable for different models.

CRUD Repository Overview

The CrudRepository implements a centralized pattern for managing CRUD operations, designed to work seamlessly with various models. Below is an explanation of its key methods and usage:

index

$this->interface->index(Model $model, $paginated, $folder, $files, $where, $whereNot, $search, $active, $verify, $relation);
  • Fetches records from the database.
  • Supports optional filters for where, whereNot, search, and status (active, verify).
  • Handles relationships ($relation) and dynamically includes image paths if $files and $folder are provided.

getById

$this->interface->getById(Model $model, $id, $folder, $files, $where, $whereNot, $search, $active, $verify, $relation);
  • Fetches a single record by ID.
  • Includes filters and dynamic file URLs, similar to the index method.

store

$this->interface->store(Model $model, $data, $request, $folder, $files, $modified_values, $hashing_values, $relation);
  • Creates a new record in the database.
  • Supports:
    • Dynamic image storage.
    • Relationships: Automatically creates related records for hasOne, hasMany, and belongsTo relations based on the $relation parameter.

update

$this->interface->update(Model $model, $data, $id, $request, $folder, $files, $modified_values, $hashing_values, $where, $whereNot, $search, $active, $verify, $relation);
  • Updates an existing record by ID.
  • Handles image updates, dynamic relationships, and field modifications.

delete

$this->interface->delete(Model $model, $folder, $id, $where, $whereNot, $search, $active, $verify, $relation);
  • Deletes a record by ID, including related images stored in the specified folder.

verify / unverify

$this->interface->verify(Model $model, $id);
$this->interface->unverify(Model $model, $id);
  • Toggles the verified status of a record.

getByDate / getBetweenDate

  • Fetch records based on specific date criteria.

getMoreThan / getLessThan

  • Fetch records where a field exceeds or is less than a specified value.

Contributing

Bug Fixes and Updates

  • Identify and fix bugs, then push changes to the bug branch for review.
  • Collaboration is encouraged! Your contributions are a big help in improving the project.
  • For new features, create branches with descriptive names, such as feature-event-name.
  • For fixes, use branch names like fix-issue-description.

We welcome collaboration and are excited to work with you to expand this project further! Please collaborate on GitHub and leave a star if you find this package useful.

Future Features

  • Role and permission-based access control is in progress and will be updated soon.
  • Improved relational data management, including:
    • Nested CRUD operations for related models.
    • Automated handling of pivot tables for many-to-many relationships.
    • Default eager loading for optimized relational queries.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Author

Niraj Bajagain (https://github.com/NeeRaj556)

neeraj/catalyst-starterkit-restapi 适用场景与选型建议

neeraj/catalyst-starterkit-restapi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 5, 最近一次更新时间为 2025 年 01 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 neeraj/catalyst-starterkit-restapi 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-22