Xboard Documentation

repository·master·Indexed 26 days ago

https://github.com/cedar2025/xboard

A high-performance modern panel system built on Laravel 11 and Octane, featuring a React-based admin interface and a Vue3-based user frontend. Xboard includes a Telegram Bot plugin for account management, a WebSocket server for node-panel synchronization, and comprehensive CLI tools for database backups, system maintenance, and migration from V2board (versions 1.7.3, 1.7.4, and dev).

Tokens
16.3K
Snippets
43
Records
97
Agent score
89%

What's inside Xboard

  1. Configure Xboard Daemon and Scheduled Tasks

    master

    To ensure background processes and scheduling work, configure the following in aaPanel using Supervisor and Shell Scripts:

    1. Queue Daemon (via Supervisor):

    • Name: Xboard
    • Run User: www
    • Running Directory: Your site directory
    • Start Command: php artisan horizon
    • Process Count: 1

    2. Scheduled Tasks (via aaPanel Task Scheduler):

    • Type: Shell Script
    • Task Name: v2board
    • Run User: www
    • Frequency: 1 minute
    • Script Content: php /www/wwwroot/site-directory/artisan schedule:run
  2. Initialize Xboard Installation

    master

    Run the installation command to set up the database and administrator account:

    docker compose run -it --rm xboard php artisan xboard:install

    Installation Configuration Details

    1. Database Configuration

    • Database Host:
      • Use mysql if the database and Xboard are in the same network.
      • If connection fails, check 1Panel: Database -> Select Database -> Connection Info -> Container Connection and use the provided Host.
      • Use the actual host for external databases.
    • Database Port: 3306 (unless changed).
    • Database Name: xboard.
    • Database User: xboard.
    • Database Password: The password created in the 1Panel setup.

    2. Redis Configuration

    • Select the option to use the built-in Redis (no extra config required).

    3. Administrator Information

    • Important: Save the admin credentials and the admin panel access URL displayed at the end of the process.
  3. Configure Xboard with Laravel Octane (Optional)

    master

    For high-performance deployments, you can use Laravel Octane. This requires an additional daemon process and specific Nginx proxy rules.

    1. Add Octane Daemon (via Supervisor):

    • Name: Octane
    • Run User: www
    • Running Directory: Site directory
    • Start Command: /www/server/php/82/bin/php artisan octane:start --port 7010
    • Process Count: 1

    2. Octane Nginx Rewrite Rules: Add these rules to proxy requests to the Octane server.

    location ~* \.(jpg|jpeg|png|gif|js|css|svg|woff2|woff|ttf|eot|wasm|json|ico)$ {
    }
    
    location ~ .* {
        proxy_pass http://127.0.0.1:7010;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Real-PORT $remote_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header Scheme $scheme;
        proxy_set_header Server-Protocol $server_protocol;
        proxy_set_header Server-Name $server_name;
        proxy_set_header Server-Addr $server_addr;
        proxy_set_header Server-Port $server_port;
    }
  4. Migrate from V2board 1.7.4 to Xboard (Docker)

    master

    To migrate from V2board version 1.7.4 to Xboard in a Docker environment, follow these steps. Note that SQLite is not supported; ensure you have completed a standard Xboard installation (via Docker Compose, aaPanel + Docker, or aaPanel) before starting.

    1. Stop the running services.
    2. Wipe the current Xboard database.
    3. Manually import your old V2board 1.7.4 database into the system.
    4. Run the migration command to transform the V2board schema to Xboard schema.
    # 1. Stop services
    docker compose down
    
    # 2. Clear database
    docker compose run -it --rm xboard php artisan db:wipe
    
    # 3. Import old database (Important)
    # Please manually import the V2board 1.7.4 database
    
    # 4. Execute migration
    docker compose run -it --rm xboard php artisan migratefromv2b 1.7.4
  5. Deploy Xboard using Docker Compose

    master

    To deploy Xboard, clone the compose branch, prepare your configuration file, and run the installation command.

    1. Clone the repository

    git clone -b compose --depth 1 https://github.com/cedar2025/Xboard
    cd Xboard

    2. Select and prepare a compose template

    Choose the template that matches your environment and copy it to compose.yaml:

    FileNetworkUse Case
    compose.sample.yamlbridge + ports 7001:7001Default (bare docker, custom reverse proxy, aaPanel + Docker)
    compose.host.sample.yamlnetwork_mode: hostaaPanel native (openresty on host)
    compose.1panel.sample.yamlbridge + external 1panel-network1Panel users (to reach 1Panel-managed MySQL/Redis)
    compose.split.sample.yamlmulti-containerK8s migration or advanced scaling
    # Example for default setup
    cp compose.sample.yaml compose.yaml

    3. Install the database

    Recommended for beginners (SQLite + Redis):

    docker compose run -it --rm \
        -e ENABLE_SQLITE=true \
        -e ENABLE_REDIS=true \
        -e ADMIN_ACCOUNT=admin@demo.com \
        xboard php artisan xboard:install

    Advanced users (Custom configuration):

    docker compose run -it --rm xboard php artisan xboard:install

    Note: Save the admin dashboard URL, username, and password provided after installation.

    4. Start services

    docker compose up -d

    5. Access the site

    • Default port: 7001
    • URL: http://your-server-ip:7001
    git clone -b compose --depth 1 https://github.com/cedar2025/Xboard
    cd Xboard
    cp compose.sample.yaml compose.yaml
    docker compose run -it --rm -e ENABLE_SQLITE=true -e ENABLE_REDIS=true -e ADMIN_ACCOUNT=admin@demo.com xboard php artisan xboard:install
    docker compose up -d
  6. Develop Artisan commands for XBoard plugins

    master

    XBoard automatically registers all command classes found in a plugin's Commands/ directory when the plugin is enabled.

    Naming Convention

    To avoid namespace collisions, always use your plugin's name as a prefix for command signatures:

    // Recommended
    protected $signature = 'telegram:test {action}';
    protected $signature = 'example:hello {name}';
    
    // Avoid generic names
    protected $signature = 'test {action}';

    Implementation Best Practices

    Error Handling

    Wrap main logic in try-catch blocks to provide clean error messages to the CLI user:

    public function handle(): int
    {
        try {
            return $this->executeAction();
        } catch (\Exception $e) {
            $this->error('Operation failed: ' . $e->getMessage());
            return 1;
        }
    }

    User Interaction

    Use built-in methods to interact with the user via the terminal:

    • $this->ask('message'): Get string input.
    • $this->confirm('message'): Ask for boolean confirmation.
    • $this->choice('message', ['opt1', 'opt2']): Prompt user to select from a list.

    Accessing Plugin Configuration

    To access configuration within a command, retrieve the plugin instance via the PluginManager:

    protected function getConfig(string $key, $default = null): mixed
    {
        $plugin = app(\App\Services\Plugin\PluginManager::class)
            ->getEnabledPlugins()['example_plugin'] ?? null;
    
        return $plugin ? $plugin->getConfig($key, $default) : $default;
    }

    Calling Other Commands

    Use the Artisan::call() method to execute other commands from within your command logic:

    Artisan::call('other-plugin:command', ['arg' => 'value']);
  7. Enable WebSocket Real-time Sync (Optional)

    master

    WebSocket enables real-time synchronization of configurations and user changes to nodes.

    1. Start WS Server (via Supervisor):

    • Name: Xboard-WS
    • Run User: www
    • Running Directory: Site directory
    • Start Command: php artisan ws-server start
    • Process Count: 1

    2. Configure Nginx: Add the following location block before the main location ^~ / block in your Nginx configuration.

    location /ws/ {
        proxy_pass http://127.0.0.1:8076;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_read_timeout 60s;
    }
  8. Install Docker for Xboard deployment

    master

    Before deploying Xboard via Docker Compose, ensure Docker is installed on your system. Use the official installation script.

    For CentOS systems, you must also enable and start the Docker service.

    curl -sSL https://get.docker.com | bash
    
    # For CentOS systems, also run:
    systemctl enable docker
    systemctl start docker
  9. Migrate configuration from v2board to Xboard in a Docker Compose environment

    master

    To migrate configuration files from v2board to Xboard when using Docker Compose, follow these steps to move settings from a PHP file into the Xboard database:

    1. Create a config directory and copy your existing v2board.php file into it.
    2. Update your docker-compose.yaml to mount the configuration file by uncommenting the volume mapping line.
    3. Run the migration command via Docker Compose.

    Note: If you have modified the admin path, you must restart your services using docker compose restart for changes to take effect.

  10. Deploy Xboard on aaPanel

    master

    To deploy Xboard in an aaPanel environment, ensure your hardware meets the minimum requirements (1+ core CPU, 2GB+ RAM, 10GB+ storage) and your OS is Ubuntu 20.04+ or Debian 10+ (CentOS 7 is not recommended).

    Follow these steps for a quick deployment:

    1. Install aaPanel: Use the official installation script.
    2. Setup LNMP: Install Nginx, MySQL 5.7, and PHP 8.2 via the aaPanel dashboard.
    3. Configure PHP: Install required extensions and enable specific functions.
    4. Create Site: Add a new website in aaPanel with MySQL and PHP 8.2.
    5. Deploy Files: Clean the site directory, clone the Xboard repository, and run the initialization script.
    # 1. Install aaPanel
    URL=https://www.aapanel.com/script/install_6.0_en.sh && \
    if [ -f /usr/bin/curl ];then curl -ksSO "$URL" ;else wget --no-check-certificate -O install_6.0_en.sh "$URL";fi && \
    bash install_6.0_en.sh aapanel
    
    # 3. Deploy Xboard (after creating site in aaPanel)
    cd /www/wwwroot/your-domain
    chattr -i .user.ini
    rm -rf .htaccess 404.html 502.html index.html .user.ini
    git clone https://github.com/cedar2025/Xboard.git ./
    sh init.sh