承接 sethsharp/blog-crud 相关项目开发

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

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

sethsharp/blog-crud

Composer 安装命令:

composer require sethsharp/blog-crud

包简介

A blog CRUD package

关键字:

README 文档

README

Latest Version on Packagist Total Downloads

Blog

A fully developed Laravel Blog CRUD package that allows you to manage blogs, tags & collections.

How does this package work? This package offers a few models and provides a great base for creating a blog page for your project. The main features are:

  1. A Blog model with the ability to add Tags and make it part of a Collection
  2. Inbuilt role system and policies to control what actions can be performed by users
  3. Built in Factories for easy seeding, development & testing
  4. Files to make CRUD easy - including Actions & Requests

The main 3 models of this package are:

  1. Blog: Containing all the columns you need for a Blog + SEO columns
  2. Tag: Help users understand the base topics of the blog (A Blog HasMany Tags)
  3. Collection: Used for concepts like a tutorial series (A blog BelongsToOne)

Example Use Case

  1. A personal blog page which you want an easy implementation for to manage blogs - check out this repository
  2. A new blog page where you can add multiple users with restrictions through the author rule + additional roles & policies

What this package does not offer This package is as non-subjective as possible so Controllers, FE Components + additional logic is up to your implementation.

Steps for Development

Installation (via composer)

composer require sethsharp/blog-crud

Adding Service Provider

Add to your config/app.php

'providers' => [
    \SethSharp\BlogCrud\BlogServiceProvider::class
]

Publishing the Migrations

Then to publish the migrations: php artisan vendor:publish --tag="blog-crud-migrations"

Publishing the Config File

Publish for when you need to edit values to suit your project:

php artisan vendor:publish --tag="blog-crud-config"

Things that you can override include:

  1. Models: Allows you to create your own models - they are automatically injected into relationships within other package models
  2. Image Driver: We use the laravel-intervention library for image resizing - this defaults to gd(), but imagick() is available
  3. Bucket Paths: Allows you to specify your own paths for S3 buckets in local & production environments

WARNING: When over writing models in the config you will no longer be able to pass your model to existing actions - as it expects the package models only. This will be fixed in a future release

Other Requirements

File System This package does rely on AWS S3 logic when it comes to file uploads, via the Blog Cover or the images you can upload within your blog. So ensure that your AWS credentials are properly configured, specifically this config file in your project config/filesystems:

's3' => [
    'driver' => 's3',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION'),
    'bucket' => env('AWS_BUCKET'),
    'url' => env('AWS_URL'),
    'endpoint' => env('AWS_ENDPOINT'),
    'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
    'throw' => false,
],

Additional requirements:

  1. It is encouraged that you explore this package, it is very straight forward and simple. But it is necessary you know what is contained within this package to suit your use case.
  2. This package implements Coding Labs Laravel Roles, so that configuration will need to be carried out as well (don't worry its nice & easy!)

Factory Integration

All models integrate a factory for ease of development so make sure to use them.

Policies

There are policies for each available model in the package to add validation/protection to your routes. They must be booted in your AppServiceProvider like so:

public function boot()
{
    Gate::policy(Blog::class, BlogPolicy::class);
    Gate::policy(Tag::class, TagPolicy::class);
    Gate::policy(Collection::class, CollectionPolicy::class);
}

Update a Blog

use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use SethSharp\BlogCrud\Models\Blog\Blog;
use SethSharp\BlogCrud\Actions\Blogs\UpdateBlogAction;
use SethSharp\BlogCrud\Requests\Blogs\UpdateBlogRequest;

class UpdateBlogController extends Controller
{
    public function __invoke(Blog $blog, UpdateBlogRequest $updateBlogRequest, UpdateBlogAction $updateBlogAction): RedirectResponse
    {
        $blog = $updateBlogAction($blog, $updateBlogRequest);

        $drafted = (bool)$updateBlogRequest->input('is_draft');

        return redirect()
            ->route('dashboard.blogs.index')
            ->with('success', $blog->title . ' successfully ' . ($drafted ? 'drafted' : 'published'));
    }
}

This is an example UpdateBlogController, using all the files from the package; Blog, UpdateBlogRequest & UpdateBlogAction. Reading each of these files will give you an understanding of what they expect - so its up to you to ensure you pass the correct information.

How does this package rely on S3

S3 is used for any images used within your content - uploading on the fly or via the blog cover. Images within the content can be achieved using the actions StoreFileAction & DestoryFileAction. For optimal S3 management you can also use the StoreBlogFileRequest - example here. This example will allow you to upload files on the fly within your content, then as you save your blog using the action, it will also call CleanBlogContentAction which makes file management so easy by ensuring your S3 and DB level are in sync. Allowing for no unused files within your content.

If you want to incorporate images with your content or just be able to build something that can integrate an editor the TipTap Editor is the best choice by far - it is what I use in mine!

Open Source

This is an open-source project, so contributions are welcome! Whether you want to add new features, fix bugs, or improve documentation, your help is appreciated. Submit your PR for review and I will review them as soon as possible.

sethsharp/blog-crud 适用场景与选型建议

sethsharp/blog-crud 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.13k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 04 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 sethsharp/blog-crud 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-01