ekoh/blog-posts

A simple blog package in php

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

This package is not auto-updated.

Last update: 2024-05-19 21:25:44 UTC


README

#Blog Posts Package

A simple blog posts package in PHP used for teaching package development in PHP on my free youtube course.

##installation

To install this package, use composer

composer require ekoh/blog-posts

##Usage

$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);