index.php. By utilizing an embedded SQLite database (music.db), it offers a seamless deployment experience. It boasts a beautiful dark UI inspired by YouTube Music, complete with user accounts, metadata editing, synchronized lyrics, PWA support, dynamic playlists, auto-generated mixes, and extensive social sharing functionality.
mp3, m4a, flac, ogg, and wav files.git clone https://github.com/HirotakaDango/PHP-Music.git
cd PHP-Music
getid3/ folder inside the project root.
xampp/php/php.ini and remove the semicolon (;) before extension=pdo_sqlite and extension=sqlite3. Restart Apache./opt/lampp/etc/php.ini, uncomment the same extensions, and run sudo /opt/lampp/lampp restart.music.db and the uploads/ folder.
chmod -R 777 . # Use appropriate permissions based on your environment
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.
ADMIN_PASSWORD constant in index.php before deploying to a public server!
Media Session API. You can control playback in the background using your keyboard media keys or mobile lock screen. Holding the "Next" or "Previous" buttons on the UI skips forward/backward by 5 seconds.[00:15.30] Never gonna give you up[00:15.30]Never gonna give you up
?share_type=album&album_name=...) that launch directly into that specific view for anyone with the link.PHP Music is architected to minimize dependencies while maximizing performance and features:
index.php file handles both the frontend HTML/JS/CSS payload and the backend REST-like JSON API via the ?action= parameter.users: Authentication, profile pictures (stored as WebP blobs), upload quotas, and verification status.music: Cached metadata (Title, Album, Genre, Duration, Bitrate) and embedded album arts (WebP blobs).favorites & playlist_songs: Pivot tables handling user relations and manual sort_order.history & play_counts: Logs exact timestamps of playback (triggered after 30 seconds of listening) to fuel the recommendation engine.follows: Tracks user-to-artist and user-to-user following relationships.?pwa=sw) caches static assets (Bootstrap, Fonts, HTML payload) using a Cache-First strategy. API calls and audio streams bypass the Service Worker to guarantee live data and HTTP Range support.get_stream endpoint natively handles HTTP_RANGE requests, allowing browsers to seek through audio files without downloading the entire file first.Access the administrative dashboard by appending ?access=admin to your URL. Log in using the admin password.
Last Upload Date and Daily Upload Count of each user to prevent abuse.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). |
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 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. |
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_recommendations |
GET | Generates "For You" shelves based on play_counts, history, and follows. |
log_play |
POST | Logs a playback event to the user's history array. |
clear_history |
GET | Wipes all play history and play counts for the logged-in user. |
toggle_favorite |
POST | Adds/removes a song from favorites. |
toggle_follow |
POST | Follows/unfollows a target user or artist. |
update_favorite_order |
POST | Accepts an array of Song IDs to rewrite the sort_order column. |
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. |
export_playlist / export_favorites |
GET | Generates a downloadable JSON representation of a playlist or favorites. |
import_playlist / import_favorites |
POST | Parses an uploaded JSON file, matches DB files, and builds a new playlist or favorites 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. |
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.
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!
[00:15.30] Lyric text instead of [00:15.30]Lyric text.