Z-BlogPHP Documentation

repository·master·Indexed 21 days ago

https://github.com/zblogcn/zblogphp

An open-source, lightweight CMS designed for high performance and extensibility, primarily targeting the Chinese market. It features a modular 'Lego-like' architecture with rich plugin interfaces and theme templates. Supports PHP 5.2 through 8.4 and multiple databases including MySQL, SQLite, and PostgreSQL. Documentation covers installation, template syntax (variables, control structures, and raw PHP blocks), coding standards based on PSR-2, and system requirements.

Tokens
42.2K
Snippets
117
Records
199
Agent score
74%

What's inside Z-BlogPHP

  1. Overview of Z-BlogPHP

    master
    Z-BlogPHP is an open-source CMS (Content Management System) designed for high performance, ease of use, and extensibility. It aims to provide a seamless writing experience for users while offering developers powerful customization through rich plugin interfaces and theme templates. It is characterized as a 'Lego-like' website program due to its high playability and modular nature.
  2. Naming conventions for Z-BlogPHP functions, classes, and variables

    master

    Follow these naming rules to maintain consistency with the Z-BlogPHP codebase:

    Functions

    • Use PascalCase (UpperCamelCase).

    Classes

    • Class Names: The first letter must be capitalized.
    • Class Properties: If a property maps to a database field, the property name must match the database field name exactly. For example, the property mem_ID should correspond to Member.ID in the database.

    Global Variables

    • Use all lowercase letters.

    Constants

    • Use ALL_UPPERCASE with underscores (_) separating words.
  3. Use variables in Z-BlogPHP templates

    master

    Z-BlogPHP templates support both outputting variables and defining variables for later use within the template logic.

    • Outputting a variable: Use the {$variable.property} or {$variable} syntax to render the value directly into the HTML.
    • Defining a variable: Use the {$variable=value} syntax to assign a value (such as a function result or a string) to a variable without rendering it immediately.
    {$article.Name}
    {$now=time()}
    {$abc="my name"}
  4. Use Z-BlogPHP standalone utility tools

    master

    Z-BlogPHP provides several standalone PHP utility files that can be used individually for common administrative tasks. These tools are designed to be run as single files within your Z-BlogPHP installation directory.

    Available utilities:
    - Z-BlogPHP Online Installation Tool: install.php
    - Z-BlogPHP Password Reset Tool: nologin.php
    - Z-BlogPHP Plugin Interface Definition Output Tool: pluginlist.php
  5. Use control structures (if, for, foreach) in templates

    master

    Z-BlogPHP provides template-specific syntax for common programming control structures, allowing you to implement conditional logic and loops directly in your templates.

    // If/Else logic
    {if $i==1}
        i=1
    {elseif $i==2}
        i=2
    {else}
        i=else
    {/if}
    
    // For loop
    {for $i  =  1 ;  $i  <=  10 ;  $i ++}
      <p>This is iteration {$i}</p>
    {/for}
    
    // Foreach loop
    {foreach $articles as $article}
      <p>{$article.Title}</p>
    {/foreach}
  6. Install Z-BlogPHP

    master

    Prerequisites

    Ensure your website directory has 755 permissions.

    Note for GitHub users: If you are using the development version from GitHub, it is recommended to first download and install the stable version, then overwrite the files with the GitHub version.

    Installation Steps

    1. Upload the Z-BlogPHP program to your website directory.
    2. Navigate to http://your-website/ in your browser to access the installation interface.
    3. Configure your database:
      • MySQL: Enter the MySQL account and password provided by your hosting provider.
      • SQLite: Ensure your server supports SQLite; the installer will automatically create the SQLite database file when you proceed.
      • PostgreSQL: Enter the hostname, database name, account, and password.
    4. Set up Administrator Account: Enter the username and password for your site administrator. Use a strong password.
    5. Click 'Next' to complete the installation.

    Post-Installation Cleanup

    To secure your installation, delete the following folders:

    • Always delete the zb_install folder.
    • If using the GitHub development version, also delete the standards, tests, and utils folders.
  7. Coding standards and file formats for Z-BlogPHP

    master

    When contributing to or extending Z-BlogPHP, follow these formatting and style guidelines to ensure compatibility and consistency.

    File Format

    • Use UTF-8 encoding.
    • Do not include a BOM (Byte Order Mark) header.

    Code Style

    Z-BlogPHP generally follows the PSR-2 coding standard, with the following specific exceptions and additional rules:

    • Line Length: There is no limit to the number of characters per line.
    • Backward Compatibility: Code must be written using syntax compatible with PHP 5.2 (e.g., do not use short array syntax [] or certain use keyword patterns that require higher versions).
    • Whitespace: Do not place multiple blank lines before a semicolon.
    • Operators: Always place a single space on both sides of an operator.
  8. Access coding standards for Z-BlogPHP applications

    master

    The main program coding standards are contained within this repository. For developers building applications or plugins on top of Z-BlogPHP, specific application coding standards are maintained in a separate document to ensure compatibility and consistency with the core system.

    https://github.com/zblogcn/zblogphp/blob/master/standards/%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83.md
  9. System requirements for Z-BlogPHP

    master

    Before installing Z-BlogPHP, ensure your server meets the following environment requirements:

    Web Server

    Supports various web servers including:

    • IIS
    • Apache
    • nginx
    • Lighttpd
    • Kangle
    • Tengine
    • Caddy

    PHP Version

    • PHP 5.2 through 8.4
    • HHVM 3

    Database Support

    • MySQL 5+
    • MariaDB 10+
    • SQLite 3
    • PostgreSQL