MCY Shop Documentation

repository·main·Indexed 19 days ago

https://github.com/lizhipay/mcy-shop

A high-performance, native PHP e-commerce system designed for small-scale entrepreneurship and large-scale distribution platforms. It features a custom framework supporting FPM and CLI, a robust plugin architecture, AES-encrypted API communication, and multi-role support for platforms, suppliers, merchants, and customers. The system utilizes hyperf/database for ORM and Twig for template rendering. It includes a comprehensive CLI toolset for managing composer dependencies, asset compression, database model generation, language packs, and systemd service integration.

Tokens
13K
Snippets
51
Records
61
Agent score
64%

What's inside MCY Shop

  1. Overview of MCY Shop System features

    main

    MCY Shop is a high-performance, native PHP e-commerce system built on a custom framework. It is designed for individual entrepreneurs and large-scale distribution platforms.

    Core Technical Architecture:

    • Framework: Custom native PHP framework supporting both FPM and CLI architectures. Suitable for virtual hosting, VPS, and high-performance cloud servers with load balancing support.
    • Database ORM: Optimized using hyperf/database.
    • Template Engine: Uses twig (by the Symfony team) for secure and high-performance rendering.
    • Security:
      • A content security filtering system that allows safe HTML usage (e.g., for product descriptions) while protecting the database.
      • All API communications are encrypted using AES binary encryption.
    • Internationalization: Full i18n support, including custom currencies and translations.

    Key Capabilities:

    • Plugin System: Supports multiple development modes including Controllers (API/VIEW), Management Menus, Console Commands, Processes (scheduled/background tasks), WebSocket (real-time communication), Payment, Sourcing (fulfillment), and HOOKs.
    • Template System: High extensibility via template HOOKs.
    • Multi-Role Support: Supports Platform (Main Site), Suppliers, Merchants (Sub-stations/Distributors), and Customers (Members).
    • Sub-station Independence: Merchants can open sub-stations that function similarly to the main site, including the ability to install their own plugins and custom payment interfaces independently.
  2. Legal Disclaimer and Usage Terms

    main

    The MCY Shop system is open-sourced under the MIT License and is free to use.

    Important Restrictions:

    • The primary purpose is for developer learning and research.
    • Commercial Use Prohibited: It is strictly forbidden to use this program for any commercial purposes without legal qualification, especially using this program to build a platform for selling goods.
    • Users must comply with all local laws and regulations.

    By using this program, you acknowledge that you have understood and agreed to these terms.

  3. Quickly experience the MCY Shop System

    main

    You can test the system using the following demo environments:

    Admin Dashboard (Backend):

    • URL: http://42.51.0.159:4399/admin
    • Super Admin Username: demo@qq.com
    • Super Admin Password: abc123456

    Storefront (Frontend):

    • URL: http://42.51.0.159:4399/
    • Sub-station/Customer Username: test
    • Sub-station/Customer Password: abc123456
  4. How Popper.js works in the project

    main

    Popper.js is used for positioning elements (like tooltips, popovers, or dropdowns) relative to a reference element. It uses a system of modifiers to calculate positions, handle overflows, and manage offsets.

    Key concepts:

    • Phases: Modifiers operate in specific phases: beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, and afterWrite.
    • Modifiers: These are functions that adjust the state of the popper. Common built-in modifiers include flip (to prevent overflow by flipping the placement), preventOverflow (to keep the popper within boundaries), and offset (to add space between the reference and popper).
    • Placements: Supported placements include top, bottom, left, right, and their variations like top-start, top-end, bottom-start, etc.

    Developers can use createPopper to initialize a popper instance with a reference element and a popper element.

    // Note: The provided segment contains the internal implementation of Popper.js
    // but does not show the high-level consumer API call. 
    // Typically, it is used as:
    // createPopper(referenceElement, popperElement, { options });
  5. System Requirements: PHP Version

    main
    The mcy-shop application requires PHP 8.1.0 or higher to run. If the environment is running a version lower than 8.1.0, the application will terminate and display a version error message. Ensure your web server is configured with a compatible PHP runtime before deployment.
  6. Uninstall the systemd service

    main

    To completely remove the application service from the system, call the uninstall() method. This performs a clean teardown:

    1. Stops the running service.
    2. Disables the service (systemctl disable) so it does not start on boot.
    3. Deletes the service file from /etc/systemd/system/.
    <?php
    $service = new 	ext{App\Command\Service}();
    $service->uninstall();
  7. Install the application as a systemd service

    main

    To install the application as a systemd service, call the install() method. This operation performs the following steps:

    1. Checks if the service file already exists in /etc/systemd/system/.
    2. If not present, creates a service unit with the following configuration:
      • Description: {name}-{port}
      • ExecStart: {BASE_PATH}/bin {BASE_PATH}/index.php
      • Restart: always (with a 3-second delay)
    3. Enables the service via systemctl enable.
    4. Automatically calls start() upon successful installation.

    Note: If the service file already exists, the command will output an error: Service installation failed. The service may already exist.

    <?php
    // Conceptual usage within the application context
    $service = new 	ext{App\Command\Service}();
    $service->install();
  8. Compress JS and CSS assets

    main

    The Compress command automates the merging and minification of JavaScript and CSS assets for different parts of the application (Common, Admin, User, and Index).

    When executed, it performs the following tasks:

    • JS Compression: Uses uglifyjs with the -c (compress) and -m (mangle) flags to merge and minify JS files into specific bundles like /assets/common/js/base.js, /assets/admin/js/admin.js, /assets/user/js/user.js, and /assets/user/js/index.js.
    • CSS Compression: Uses cleancss to merge and minify CSS files into bundles like /assets/admin/css/admin.min.css, /assets/user/css/user.min.css, and /assets/user/css/index.min.css.

    Note: This command relies on shell_exec to invoke the installed Node.js binaries.

  9. Initialize the application via index.php

    main
    The index.php file serves as the web server entrypoint. It performs a version check and then bootstraps the application by requiring the kernel/Kernel.php file. To use this project, point your web server's document root to the directory containing this file.
  10. Install dependencies for asset compression

    main

    The Compress command requires Node.js and two specific global NPM packages to function. You must install these tools via npm before running the compression command:

    1. uglify-js: Used for minifying JavaScript files.
    2. clean-css-cli: Used for minifying CSS files.

    Install them using the following commands:

    npm install uglify-js -g
    npm install clean-css-cli -g
  11. Configure application debug mode and version

    main

    The config/app.php file defines the core application settings. You can control the application's debug state and specify the version string.

    • debug (bool): Set to true to enable debug mode, or false to disable it.
    • version (string): The current version identifier of the application.
    return [
        'debug' => false,
        'version' => '5.0.34'
    ];