This repository contains the PHP code for the SiaGraph website and API.
- PHP 8.2+ (tested on 8.4) with extensions:
mysqli(required)ctype,json,tokenizer(required)bcmath(optional; a polyfill is bundled)
- MySQL server (required)
- Redis server (optional but recommended for caching)
- Composer for PHP dependencies
- Node.js + npm (only if rebuilding CSS)
Notes:
- If you use PHP-FPM behind Nginx/Apache, ensure the MySQL extension is installed for the PHP version your web server runs (e.g.,
php8.4-fpm). The CLI can have different modules loaded than FPM.
- Copy
include/config.php.exampletoinclude/config.phpand edit values:cp include/config.php.example include/config.php
- Set
databasecredentials. - Optionally set
redis_ip(defaults to127.0.0.1).
- Set
- No other files need copying.
include/database.phpexists for backward compatibility and simply loadsbootstrap.php.
Install PHP dependencies from the repository root:
composer install --no-devThis generates the vendor/ directory (do not commit it).
Run locally using PHP’s built‑in server:
php -S localhost:8000Visit http://localhost:8000.
If you see “Class mysqli not found”, install the MySQL extension for your PHP CLI (e.g., Debian/Ubuntu: apt-get install php8.4-mysql).
The SCSS sources live in the scss/ directory. Card styles are defined in
scss/components/blocks/_card.scss and the responsive container layout in
scss/core/_layout.scss. To regenerate css/style.css install the Node
dependencies and run the Mix build:
npm install
npm run prod # one-time build
# or `npm run dev` to watch during developmentapi/ API endpoints (v1) and Swagger definition
css/ Stylesheets
graphs/ PHP classes for graph generation
img/ Images and icons
include/ Shared config and helper files
swagger/ Swagger UI for the API
vendor/ Composer dependencies (generated by Composer; not tracked)
Major pages in the project include:
index.php– main network dashboardhost_overview.php– host distribution and statisticshost_explorer.php– search and view details about a single hostnetwork_growth.php– historic growth chartsnetwork_storage.php– storage usage and host totalsnetwork_aggregates.php– aggregated metrics over timepeers.php– map of peers currently onlinetoken_volume.php– network volume informationtokenomics.php– token supply and economics overviewrevenue.php– contract revenue and burned fundshosting.php– overview of hosting pagesnetwork_overview.php– overview of network pagessiafunds_overview.php– overview of Siafunds metrics
Ensure the PHP‑FPM version Nginx uses has mysqli enabled. On Debian/Ubuntu:
apt-get update
apt-get install -y php8.4-fpm php8.4-mysql
systemctl enable --now php8.4-fpmExample Nginx server block:
server {
listen 80;
server_name example.com;
root /var/www/html/siagraph-web-codex;
index index.php index.html;
location / {
try_files $uri $uri/ @extensionless_php;
}
location @extensionless_php {
rewrite ^/(.*)$ /$1.php last;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock; # match your PHP version
}
}
Avoid defining multiple location ~ \.php$ blocks with different PHP versions; Nginx will use the first regex match which can be confusing.
- CLI:
php -m | grep -i mysqli - FPM: create
/var/www/html/siagraph-web-codex/info.phpwith<?php phpinfo();and load it in a browser to confirmmysqliis listed.
- Error:
Class "mysqli" not found- Install the MySQL extension for the PHP SAPI you’re using:
- Debian/Ubuntu CLI:
apt-get install php8.4-mysql - Debian/Ubuntu FPM:
apt-get install php8.4-mysql && systemctl restart php8.4-fpm
- Debian/Ubuntu CLI:
- Ensure Nginx points to the same PHP version you installed the module for.
- Install the MySQL extension for the PHP SAPI you’re using: