PHP Music

A simple, fast, and modern self-hosted music player built entirely in a single PHP file.

Galleries

Screenshot 1 Screenshot 2 Screenshot 3 Screenshot 4 Screenshot 5 Screenshot 6 Screenshot 7 Screenshot 8
Introduction
PHP Music is an open-source, web-based, self-hosted music platform contained entirely within a single index.php file. By utilizing an embedded SQLite database (music.db), it offers a seamless deployment experience with no complex database setup required. It boasts a beautiful dark UI inspired by YouTube Music, complete with user accounts, metadata editing, synchronized lyrics, full PWA support, dynamic playlists, collaborative playlist contribution, an advanced audio engine, auto-generated mixes, an integrated Markdown blogging platform, a multi-layered HTML5 image editor, a fully functional rhythm game engine, an integrated PHPEditor IDE, and extensive social sharing functionality.
Features
Library Management
Browse by songs, artists, albums, or genres. Features infinite scrolling, rapid local search, and diverse sorting options.
Blogging Platform & Markdown Editor
Publish public posts or save private drafts. Features live Markdown preview, Find & Replace tool, auto-saving drafts, real-time word/character count, categories, and multi-format exports (PDF, HTML, MD, TXT, or ZIP). Includes blog-level likes/dislikes and threaded comments with nested replies (read-only for guests).
Integrated PHPEditor (IDE)
Desktop-optimized browser code editor built on Ace Editor. Supports syntax highlighting (PHP, JS, CSS, HTML, JSON), multi-tab file management, file tree explorer, file history & rollback, and an interactive terminal console.
Built-in Rhythm Game Engine
Challenge yourself on custom generated maps using tracks from your library. Features a structured hub with Songs, Favorites, Settings, and global Ranks tabs. Difficulty ranges from Easy to Master, with latency calibration, note tick-speed modifiers (up to 20x), mid-game pausing, retries, and high-score boards with Full Combo (FC) badges.
Advanced HTML5 Image Editor (ImagEditor)
Create covers or edit pictures with a multi-layered canvas workspace. Import images, inject editable text layers, append shapes, drag, rotate, resize, toggle flip orientations, manage layer orders, apply filters (brightness, contrast, grayscale), and export files as high-resolution PNGs, JPEGs, WEBP, SVG, or project JSON. Includes brush tools with symmetry modes and 25+ design templates.
PHPAudio โ€“ Audio Editor
Edit audio files directly in your browser: trim, amplify, adjust volume, and update metadata (title, artist, album, cover art). Uses the Web Audio API for waveform rendering and trimming; getID3 for metadata extraction; supports saving edited tracks back to the library with updated tags and cover images. Includes version rollback for library tracks.
PHPShares โ€“ Artwork & Manga Gallery
Upload and share illustrations and manga with tags, series, characters, parodies, groups, and NSFW flagging. Browse by tags, characters, parodies, groups, or series. Manga reader with page navigation, keyboard controls, and episode selectors. Favorites and threaded comments with markdown and @mentions.
Unlimited Offline Listening
Cache song files, cover art, and metadata into browser Cache Storage. Works completely offline. Missing files automatically dim and show warning alerts inside the Offline Music page.
Local Device Export
Download cached songs directly from local storage into physical files to save data. This option dynamically displays in context menus only for fully cached files.
ID3 Tags, Synced Lyrics & 1:1 Cropping
Modify song metadata and LRC lyrics directly. Features an integrated 1:1 ratio image cropper (with panning and zoom to fill gaps) for profile pictures and cover art, accompanied by real-time upload progress bars showing percentage feedback.
Advanced Audio Engine
Features a built-in, togglable 5-band Graphic Equalizer (60Hz, 230Hz, 910Hz, 3.6kHz, 14kHz) and automatic real-time Volume Normalization (AGC) via Web Audio API to prevent uneven audio levels.
Gapless Playback & Crossfade
Enjoy seamless track transitions via a dual HTML5 audio node system, automatically crossfading outgoing and incoming tracks over an adjustable 3-second period.
Dynamic Queue Management
YouTube Music-style "Up Next" dynamic play queue. Supports "Play Next" and "Add to Queue" context menu options. Player modals feature an "Up Next" queue tab with on-demand infinite scrolling.
Infinite Autoplay (Station Mode)
When your active play queue is exhausted, the app automatically transitions to Station Mode, appending 15 similar recommended tracks based on the genre and artist of your last played song.
Collaborative Playlists
Invite specific users by email or exact display name to contribute tracks. The UI securely tracks contributors, showing "Added by [User]" inline. Toggling back to Private purges collaborators and their access.
Draggable Sleep Timer & NoSleep.js
Schedule playback to auto-pause. Features a draggable, floating countdown bubble and a robust screen stay-awake mechanism driven by NoSleep.js (silent HTML5 video loop fallback) to prevent mobile display timeouts.
Playlist Downloader
Built-in sequential downloader interface. Batch download entire playlists directly to your hard drive, or grab single tracks by ID with real-time logging.
Protected Uploads
Upload multiple songs simultaneously. Features a daily limit (default: 10 songs/day, resetting at midnight) and requires explicit admin verification to prevent abuse.
Soft Delete & Recovery
Soft-delete your account credentials while keeping your upload data intact. Generate a backup key to restore your profile details and reclaim ownership later.
Recommendations & Mixes
The "For You" tab generates personalized shelves (Recently Played, More from top artists) and auto-mixes based on listening history, top genres, and followed creators.
Bookmark-based Listen Later
Save tracks to a personalized sortable queue using outline and filled bookmark icons. Manual reordering is saved natively to the database.
Community Social Feed
Share public posts with support for editing, deletion, and reactions (likes and dislikes). Feeds can be filtered by newest posts, highest likes, or only users you follow.
Song Conversations & Comment CRUD
Engage in song-level discussions with fully featured threaded nesting, direct replies, likes/dislikes on comments, `@username` tags, and individual edit/delete operations.
Personal Notes System
A sandboxed, private notebook to compile thoughts, song lists, or lyrics, sortable dynamically by newest, oldest, and modified timestamps.
Direct Messaging (Inbox)
Real-time peer-to-peer messaging system. Features read/unread indicators, image attachments, message editing/deletion, an inbox search tool, and live user online/active status presence.
Interactive Calendar & Clock
A built-in interactive calendar widget. Jump between dates using the date-picker, easily return to today, and view the current time running on a real-time interval clock.
Personal Privacy & Admin Override
Toggle playlists, uploaded tracks, or blogs to Personal Private mode to keep them strictly invisible and unplayable/unreadable to other accounts. Private items are automatically filtered out from other users' play queues, search results, and public lists. The system administrator account (musiclibrary@mail.com) maintains a global override to safely access all private assets.
Integrated Drive Backend
A robust PHPDrive backend manager for the administrator. Features dynamic deep-linking URLs, a responsive 2-column mobile grid, native .zip extraction via context menus, 1-year admin sessions, and file property calculations.
Upload Modal Collaborator Search
The upload modal features the same search-by-name/email panel as the "Manage Collaborators" view, allowing you to select and manage collaborators as clear pill badges before uploading.
Rhythm Game Offline Check & Progress
Automatically detects cached states on the offline rhythm list. Uncached tracks dim to 40% opacity, display a "Not cached offline" warning badge, and block playing when fully offline. Includes a real-time progress loader showing exact download percentages.
Responsive Drive Editor & Scrolling
The file editor features dynamic tab-title syncing, auto-refresh to prevent layout overlaps, and optimized scroll overflows. The Admin Sidebar now scrolls independently from main content view blocks.
Installation & Setup
  1. Clone the repository:
    git clone https://github.com/HirotakaDango/PHP-Music.git
    cd PHP-Music
  2. Dependencies: Ensure PHP 7.4+ is installed. Download the latest getID3 library and extract it into a getid3/ folder inside the project root folder.
  3. Enable SQLite in PHP: PHP Music runs entirely on SQLite. If you are using XAMPP/LAMPP, you may need to enable it manually.
    • XAMPP (Windows/macOS): Open xampp/php/php.ini and remove the semicolon (;) before extension=pdo_sqlite and extension=sqlite3. Restart Apache.
    • LAMPP (Linux): Open `/opt/lampp/etc/php.ini`, uncomment the same extensions, and run `sudo /opt/lampp/lampp restart`.
  4. Permissions: PHP must have write permissions to the project directory to create music.db and the uploads/ folder.
    chmod -R 777 . # Adjust permissions as per your server's security standards
  5. Run the app:
    php -S localhost:8080
    Open http://localhost:8080 in your browser. Register an account, log into the admin panel (?access=admin, password: admin) to verify yourself, and hit "Scan All" to build your library.
Security Tip: Change the ADMIN_PASSWORD constant in index.php before deploying to a public server!
Usage Guide
Technical Architecture

PHP Music is built to minimize dependencies while maximizing performance:

Admin Panel

Access the administrative dashboard by appending ?access=admin to your URL. Log in using the admin password (default: your admin password). Admin sessions are highly persistent and securely cached in the browser via a 1-year cookie.

API Endpoints

The backend operates via GET/POST requests targeting ?action=.... All responses (except file streams and images) return strict JSON.

Endpoint Method Description
get_session GET Returns active user profile, daily limits, and auth status.
register / login POST Handles authentication. Requires JSON payload (email, password). Sets active sessions for up to 1 year.
restore_account POST Restores an account mapping using a generated backup key.
delete_account_keep_data GET Wipes user credentials and email, but keeps user data (music, notes, tasks, blogs) and generates a backup key.
upload_profile_picture POST Accepts Multipart form data. Crops image 1:1, resizes to 200px, converts to WebP.
full_scan GET Recursively syncs disk files with the DB. Triggers getID3 parser for missing files.
upload_song POST Accepts MP3/FLAC/OGG. Parses ID3 tags immediately. Checks daily limit.
edit_metadata POST Updates DB and writes ID3v2/Vorbis tags (including lyrics) directly into the audio file. Saves covers in dedicated covers/songs and covers/albums folders.
get_songs GET Returns paginated songs. Supports parameters: sort, page, artist, album, genre, filter_user_id.
get_view_data GET Aggregates data for deep links. Supports types: profile, playlist, artist, album.
get_blogs GET Fetches blog posts. Supports parameters: sort, filter, q (search), artist_id.
get_blog GET Retrieves a single blog post by its public_id.
save_blog POST Creates or updates a blog post.
delete_blog POST Deletes a blog post by ID.
export_blogs GET Generates a downloadable JSON export of user blogs.
import_blogs POST Parses an uploaded JSON file and imports blog posts.
get_blog_comments GET Retrieves threaded comments, parent-child replies, blog reactions, and comment likes/dislikes.
toggle_blog_reaction POST Registers a like or dislike on a blog post.
toggle_blog_comment_reaction POST Registers a like or dislike on an individual blog comment.
add_blog_comment / edit_blog_comment / delete_blog_comment POST Full CRUD operations on blog comments and nested replies.
get_recommendations GET Generates "For You" shelves based on play_counts, history, and follows.
log_play POST Logs a playback event (after 30 seconds) to compile user history.
clear_history GET Wipes all play history and play counts for the logged-in user.
toggle_favorite POST Adds/removes a song from favorites.
get_listen_later / get_listen_later_ids GET Fetches detailed metadata lists or raw IDs of bookmarked songs.
toggle_listen_later POST Adds/removes a song from the listen later bookmarks.
update_listen_later_order POST Accepts an array of Song IDs to rewrite the position mapping of bookmarks.
get_notes GET Fetches private sandboxed personal notes. Supports sorting.
save_note POST Creates a new note or edits an existing note.
delete_note POST Deletes a specific note.
get_song_comments GET Fetches comment trees, overall song reactions, and comment likes/dislikes.
toggle_song_reaction POST Registers a like or dislike on a specific song.
toggle_comment_reaction POST Registers a like or dislike on an individual comment.
add_song_comment / edit_song_comment / delete_song_comment POST Full CRUD operations on individual track-level comments.
get_community GET Fetches public status posts with like/dislike counts and author info. Supports sorting.
create_community_post / edit_community_post / delete_community_post POST Full CRUD operations on community posts.
toggle_post_reaction POST Registers a like or dislike on a community post.
toggle_offline POST Adds/removes a song from offline cache database mapping.
get_offline_ids GET Fetches list of cached/offline song IDs mapped to the user.
get_offline_songs GET Fetches detailed metadata list of cached/offline songs.
toggle_follow POST Follows/unfollows a target user or artist.
toggle_block POST Blocks/unblocks a target user, preventing follows and direct messages.
get_inbox / get_chat GET Fetches conversation summaries and direct peer-to-peer message history.
send_message / edit_message / delete_message POST Handles sending (with image support), modifying, and deleting direct messages.
toggle_collaborative POST Toggles playlist collaborative state and deletes collaborators if made private.
manage_collaborators POST Adds, removes, or lists collaborators on a playlist.
get_queue_songs POST Fetches song metadata for a batch of IDs inside the dynamic play queue.
get_radio_tracks GET Generates 15 recommended tracks based on a seed song ID's genre/artist for Autoplay.
update_favorite_order POST Accepts an array of Song IDs to rewrite the sort_order column.
update_offline_order POST Accepts an array of Song IDs to rewrite position map of offline list.
create_playlist POST Generates a new playlist with a unique 8-byte hexadecimal public_id.
copy_playlist POST Clones another user's public playlist into the active user's account.
unzip (Drive API) POST Extracts a .zip archive directly on the server filesystem. Requires Admin session.
properties (Drive API) GET Calculates recursive byte sizes and structural counts (files/folders) for directories.
get_versions / restore_version (Drive API) POST Retrieves file snapshot history and restores files to past versions. Requires Admin session.
terminal_cmd (Drive API) POST Executes safe terminal commands (git, ls, pwd, php -v) on the server. Requires Admin session.
export_playlist / export_favorites / export_offline GET Generates a downloadable JSON representation of a playlist, favorites, or offline music list.
import_playlist / import_favorites / import_offline POST Parses an uploaded JSON file, matches DB files, and builds target playlist, favorites, or offline list.
download_song GET Downloads the specific song audio file as an attachment.
get_stream GET Streams the physical audio file with 206 Partial Content (HTTP Range) support. Handles offline stream cache reading.
save_rhythm_score POST Saves a user's raw score, maximum combo, and precise perfect/great/good hit metrics to the database.
get_rhythm_leaderboard GET Aggregates and returns the global player standings sorted by accumulated total scores. Limits to top 25 users.
get_song_rhythm_leaderboard GET Fetches top 25 high scores recorded specifically for a single song ID, flagging Full Combo achievements.
toggle_rhythm_favorite POST Toggles a song's favorite state inside the rhythm game ecosystem.
get_rhythm_favorites GET Retrieves the complete list of favorited rhythm game track IDs mapped to the user.
upload_art POST Uploads artwork images (single or multiple) with metadata, tags, series, and NSFW flag. Stores files in `phpshares/`.
get_arts GET Fetches a paginated list of artworks with filtering by type (image/manga), search, tags, characters, etc.
get_art GET Retrieves a single artwork with all its files, comments, and metadata.
toggle_art_favorite POST Adds/removes an artwork from the user's favorites.
add_art_comment / edit_art_comment / delete_art_comment POST CRUD operations on artwork comments with nested replies.
get_arts_explore GET Returns popular tags and trending artworks/manga for the explore page.
get_series_details GET Fetches a series with its aggregated metadata and list of works.
save_imageditor_project POST Saves an image editor project (title, dimensions, state JSON, category, starred) to the database.
get_imageditor_projects GET Lists the user's saved image editor projects with filtering and search.
toggle_imageditor_star POST Toggles starred status on an image editor project.
delete_imageditor_project POST Deletes a saved image editor project.
inspect_audio POST Uploads an audio file temporarily and returns its getID3 metadata (format, bitrate, duration, etc.) for the PHPAudio editor.
save_audio_editor POST Saves an edited audio file (including trimmed clip, metadata, cover art) to the library. Supports creating new or updating existing songs.
get_song_versions / restore_song_version POST Fetches version history for a song and restores a previous version.
Troubleshooting & FAQ

Ensure the getid3/ directory exists and is accessible. Make sure PHP has read/write permissions for the local files and the project root (to create music.db). If using XAMPP/LAMPP, ensure SQLite extensions are activated in php.ini.

Make sure the uploads/ directory is writable. Check your php.ini settings for upload_max_filesize and post_max_size and ensure they are large enough (e.g., 50M) to accommodate FLAC or WAV files. Also, verify your account is verified by the admin!

If the database updates but the physical file tags do not change, check the file permissions of the specific MP3/FLAC file. PHP needs write permissions to the file to utilize the getID3 tag writer. Note that updated cover artwork is saved to the database, embedded into file tags, and mirrored in dedicated covers/songs and covers/albums directories.

Some files may lack embedded images. The app uses a default SVG icon as a fallback. You can manually assign a cover via the "Edit Metadata" context menu option (requires a 1:1 cropped image).

PHP Music supports the standard LRC format for synchronized lyrics. If your lyrics appear as plain text instead of syncing with the playback, ensure that each timestamp is followed by a space. For example, use [00:15.30] Lyric text instead of [00:15.30]Lyric text.

Collaborative Playlists let you invite specific users by email or display name to edit a playlist. Note that the "Manage Collaborators" button in the playlist context menu is strictly visible only when the playlist is set to Collaborative. If you change a playlist's status back to Private, all invited collaborators and their contribution permissions are automatically deleted from the database.

Ensure the phpshares/ directory is writable and has proper permissions. Check that GD or ImageMagick is installed and enabled in PHP for image processing. Large images may time out; consider increasing memory_limit and max_execution_time in php.ini.

Check the browser console for JavaScript errors. Fabric.js may fail to load if there are network issues. Ensure you have enough memory in the browser; large images may cause the canvas to be blank. Try resetting the canvas or loading a smaller image.