ekoh/blog-posts

dev-master 2023-06-05 07:45 UTC

This package is not auto-updated.

Last update: 2024-09-22 23:09:01 UTC


README

#博客文章包

这是一个简单的PHP博客包,用于在我的免费YouTube课程上教授PHP包开发。

##安装

要安装此包,请使用composer

composer require ekoh/blog-posts

##用法

$blog = Blog::getInstance();

$postArray = [
                 'id' => 1,
                 'Title' => 'Post title',
                 'image' => 'Path/to/image (optional)',
                 'body' => 'post body',
                 'author' => 'author',
                 'hidden' => 0,
                 'comments' => []
             ];

$blog->addPost($postArray);


$blog->getPosts($offset, $limit);

$blog->editPost($postId, $postArray);

$blog->getPost($postId);

$post = new Post($postId);

$commentArray = [
                   'body' => 'post comment',
                   'author' => 'optional'
               ];

$post->addComment($commentArray);

$post->getComments($offset, $limit);

$post->editComment($commentId, $commentArray);