承接 bryceandy/press 相关项目开发

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

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

bryceandy/press

Composer 安装命令:

composer require bryceandy/press

包简介

A markdown blog for Laravel

README 文档

README

Actions Status Total Downloads Latest Stable Version License

This Laravel package can be used to publish and update your blogs using markdown files.

✅ Locate where your markdown files are (i.e local file directory, cloud)
✅ Create or update these files
✅ Select custom fields for your posts
✅ Customize how any extra field can be parsed
✅ Choose when to publish or update the posts by scheduling a command

Requirements

Your project needs to meet the following requirements:

  • PHP version >=7.4
  • Laravel version 7 and above
  • ext-json installed

Installation

Run the following command on your terminal to install the package

composer require bryceandy/press

Usage

Publish configurations and run migrations

Run the following artisan command, and the config file press.php will be published in the config directory.

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

You may require to store your markdown files in a specific driver. But currently this package supports the local file driver.

Update the configuration option file.path in the published file with the directory where you will store your markdown files.

If you do not update this path make sure you create a blogs directory in the root of the project and store your files.

php artisan migrate

You should also run the artisan migrate command to add the posts table.

Markdown files syntax

The posts of your blog will have one required field title, and your own custom fields. The following is a sample syntax for your markdown files:

---
title: Post title  
field1: Additional field  
field2: Another additional field  
---  
The body of your post here  

Customize parsing of additional fields

If you wish to customize how an additional field is parsed (saved in the database), or you may wish to override how the title field is parsed:

Suppose we want to create a birthday field that should be parsed as a Carbon instance

  1. Add the birthday field in the mardown file of your post
---
title: An awesome post  
birthday: Jan 20, 2020  
field: Another field  
field2: Yet another field  
---  
The rest of the body  
  1. Create a custom class for the field and extend the FieldContract class

  2. Inherit the static process method and return the value of $field in an array

<?php

namespace App\Fields;

use Bryceandy\Press\Contracts\FieldContract;
use Carbon\Carbon;

class Birthday extends FieldContract
{
    public static function process($field, $value, $data)
    {
        return [
            $field => Carbon::parse($value),
            // or $field => $value,
        ];
    }
}
  1. Publish the Press service provider,
php artisan vendor:publish --tag=press-provider

Do not forget to register the published service provider and the Press facade in the config/app.php file

/*
 * Package Service Providers...
 */
 App\Providers\PressServiceProvider::class,

/**
 * Aliases
 */
 'aliases' => [
    ...
    'Press' => Bryceandy\Press\Facades\Press::class,
 ],
  1. Register the field class

In the service provider you will find the registerFields method, and thats where you are required to register custom field classes,

private function registerFields()
{
    return [
        \App\Fields\Birthday::class,
    ];
}

Publishing posts

When you are ready to publish your posts, or update existing an one, you may run the following command or schedule it to run in the background whenever you want

php artisan press:process

Fetching your posts

If you could successfully run the previous command that means your posts are saved in your posts table.

You may use the Bryceandy\Press\Post model to fetch posts.

The custom fields

When retrieving all custom fields you may use the extra field in the following way:

$post = Bryceandy\Press\Post::all()->first();

// The field that was parsed with the Birthday class
$birthday = $post->extra('birthday');  

// The field that was only written in the markdown file without a custom class to parse
$field = $post->extra('field');   

// Other fields  
$title = $post->title;
$body = $post->body;  

Upcoming features

🔘 Support for cloud drivers, specifically Amazon S3.

License

MIT license.

Feel free to submit pull requests to contribute to the package.

bryceandy/press 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-29