← BACK TO PORTFOLIO

MINIX-PHP

A lightweight social network written in plain PHP — no framework — on a cloud PostgreSQL database, with posts, likes, comments, and a feed built from your friends.

RoleBackend Developer
StackPHP 8.2, pgsql extension
DatabasePostgreSQL on Supabase
HostingRailway

OVERVIEW

MiniX-PHP is a small social network I built without a framework, to understand what frameworks normally hide: sessions, password hashing, routing by page, and talking to PostgreSQL directly.

Users register, sign in, publish posts, like and comment, search for other people, and build a friends list. The home page shows their own posts next to a feed of their friends’ posts, each with a live like count.

ARCHITECTURE

Each page is its own controller: it checks the session, handles any form it received with a POST → redirect → GET pattern (so a refresh never re-submits), then queries and renders.

reg.php / log.php
Registration and login. Input rules are checked first, then the database is queried.
index.php
The home page: create posts, like, comment, add or remove friends, search users, and render both feeds.
edit_profile.php
Change username and, optionally, password; the update query is built only from the fields provided.
Shared connection
One connection file included by every page, using PHP’s native pgsql extension over SSL.

DATA MODEL

Five tables. Friendship is stored in both directions, one row per side, which keeps the “my friends” and “friends’ posts” queries simple.

users
id, username, password
posts
id, user_id, title, content, created_at
likes & comments
likes(post_id, user_id)
comments(post_id, user_id, comment)
friends
friends(user_id, friend_id)

FEATURES

  • Accounts: usernames limited to letters, numbers, and underscores; passwords of at least 8 characters with letters and digits, stored with password_hash and checked with password_verify.
  • Posts, likes, comments: each user can like a post once — the server checks before inserting.
  • Friends: add or remove in one action, with a guard against duplicates; case-insensitive user search that excludes yourself.
  • Feeds: your posts and your friends’ posts, newest first, each with its like count.

SECURITY CHOICES

Parameterized SQL everywhere
Every query goes through pg_query_params, so user input is never concatenated into SQL.
Escaped output
User-supplied text is escaped with htmlspecialchars before it is rendered.
Session guard
Every private page redirects to login when there is no session; logout destroys it completely.

DEPLOYMENT

Deployed on Railway with a Nixpacks build that installs PHP 8.2 and the PostgreSQL extension, then serves the app with PHP’s built-in server. The database lives on Supabase.

git clone https://github.com/AAFLY99/MiniX-PHP.git
cd MiniX-PHP
php -S localhost:3000

NEXT STEPS

Configuration
Read database credentials from environment variables instead of a source file.
CSRF protection
Add tokens to every form that changes data.
Media & real time
Image uploads and live notifications for likes and comments.