Giter Site home page Giter Site logo

php-my-blog's Introduction

PHP-My-Blog

This is my PHP project from the Udemy course. It is the CMS application for post publishing.

Dependencies:

  • PHP 8.1.2
  • MySQL 8.0.33
  • Apache2 2.4.52
  • PhpMyAdmin 8.0.33
  • Bootstrap5 5.3.0
  • JQuery 3.7.0
  • JQuery Validation Plugin 1.19.5
  • JQuery DateTimePicker
  • PhpDocumentor 3.3.1 (optional)

Installation:

Notes: I use Ubuntu, so installation algorithm is described for this system.

Also I write the algorithm for installation of the last programs' versions. I use this site for it: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu-22-04

AND

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-22-04.

  1. Install Apache2, PHP, MySQL and PhpMyAdmin. There are a lot of guides how to install LAMP and config it. For PHP you can use:
sudo apt update
sudo apt install php libapache2-mod-php php-mysql
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl
  1. Config apache virtual host. The document root for your site in the virtual host has to be:
<VirtualHost '...':80>
    ServerName 'your_domain'
    ServerAlias www.'your_domain' 
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/public/'your_domain'
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
  1. Clone the project:
git clone https://github.com/BabaykaBo/PHP-My-Blog.git
  1. In PhpMyAdmin you can use this SQL for creating tables:
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

CREATE TABLE `category` (
  `id` int NOT NULL,
  `name` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `post` (
  `id` int NOT NULL,
  `title` varchar(128) COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `published_at` datetime DEFAULT NULL,
  `image_file` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `post_category` (
  `post_id` int NOT NULL,
  `category_id` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `user` (
  `id` int NOT NULL,
  `username` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL,
  `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;


ALTER TABLE `category`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `post`
  ADD PRIMARY KEY (`id`),
  ADD KEY `title` (`title`);

ALTER TABLE `post_category`
  ADD PRIMARY KEY (`post_id`,`category_id`),
  ADD KEY `category_id` (`category_id`);

ALTER TABLE `user`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `username` (`username`);


ALTER TABLE `category`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

ALTER TABLE `post`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

ALTER TABLE `user`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;


ALTER TABLE `post_category`
  ADD CONSTRAINT `post_category_ibfk_1` FOREIGN KEY (`post_id`) REFERENCES `post` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  ADD CONSTRAINT `post_category_ibfk_2` FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;

  1. Rename __config.php into config.php and replace '...' on actual data.
  2. Give access to uploading folder:
sudo chown -R :'www-data' public/uploading/
  1. in PhpMyAdmin in user table create user (name and password). Password should be hashed, for example, use this site: https://randommer.io/Hash/SHA256
  2. Restart apache server and go to your site in browser:
http://'your_domain_or_IP'
  1. Optional: install and config phpDocumentor.

Features:

User authentication system

  • login and logout existing user.
  • unauthorized users can only watch the content, another functionality will be unavailable.

Guest

  • view a list of post.
  • view an information about the specific post.

Admin

  • All features accessible for guest.
  • Create new posts.
  • Edit posts.
  • Edite an image for posts.
  • Delete posts.
  • Delete an image for posts.
  • Have access to admin page.
  • Publish posts.

php-my-blog's People

Contributors

babaykabo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.