Skip to content

Migrating version 0.11 to 1.0.0

Table of Contents


New Features

Query Builder

ZubZet now includes a Query Builder based on CakePHP\Database. This provides a more intuitive and powerful way to create and manage complex MySQL queries.

Routing

Alongside the existing file-internal routing system (controller-based actions), ZubZet now also provides a flexible route definition system.

This new approach allows you to explicitly declare routes, assign them to specific HTTP methods (GET, POST, …), and forward them to controller actions. It makes routing more organized, supports route grouping, and gives you greater control over your application’s structure.


Deprecated Features

ZubZet Core

  1. Localization System The currently implemented localization system in ZubZet is considered deprecated. While it has served its purpose for handling multiple languages and regional variations, its architecture no longer meets the evolving requirements of the platform. As a result, it will soon be replaced with a more efficient, flexible, and maintainable solution that better aligns with future development goals and user needs.

Other Changes

Project Structure

For better project organization, several structural changes have been introduced:

  • All developer-related files (z_controllers, z_models, z_views, z_database, …) have been moved to the app/ directory. This keeps the application logic and internal code well-structured and separated from public-facing resources.

  • A new webroot/ directory has been added to contain all public files. Any files that should be publicly accessible (e.g. assets like images, CSS, or JavaScript) should be placed here. In contrast, private files such as configurations and settings remain in the project’s root directory, ensuring they are not exposed.


Upgrade Steps

  1. Move the following folders:

    - z_controllers   → app/Controllers
    - z_models        → app/Models
    - z_views         → app/Views
    - z_database      → app/Database
    - routes          → app/Routes
    

  2. In package.json, rename:

    package.json change
    - z_database/import.php
    + app/Database/import.php
    

  3. Create a new folder called webroot.

  4. Delete the existing .htaccess file. Then create a new .htaccess file inside webroot:

    .htaccess
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule . index.php [L,QSA]
    

  5. Move everything that should be publicly accessible into webroot (e.g. assets/).

  6. Create a new index.php inside webroot:

    index.php
    <?php
    
        // -----------------------------
        // Do not change this file as it is the entrypoint for web requests.
        // -----------------------------
    
        chdir(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
    
        // Try multiple locations for the entry scripts
        $entryScripts = [
            "index.php",
            "zubzet.php",
            "zubzet",
        ];
    
        $entryScriptFound = false;
    
        foreach($entryScripts as $entryScript) {
            if(!file_exists($entryScript)) break;
    
            require_once $entryScript;
            $entryScriptFound = true;
        }
    
        // If no entry script is found, return a 500 error
        if(!$entryScriptFound) {
            http_response_code(500);
            echo "No entry script found.";
            exit(1);
        }
    
    ?>
    

  7. Run the following command to require the desired version and update your composer.json accordingly:

    composer require zubzet/framework:1.0.0
    

  8. Then, update the package to make sure all dependencies are resolved correctly:

    composer update zubzet/frameworkDatums
    

Upgrade script for Linux The script must be in the root directory, and the project inside /app
  #!/bin/bash

  cd app || exit 1




  # App folders
  mkdir -p app
  [ -d z_controllers ] && mv z_controllers app/Controllers
  [ -d z_models ]      && mv z_models      app/Models
  [ -d z_views ]       && mv z_views       app/Views
  [ -d z_database ]    && mv z_database    app/Database
  [ -d routes ]        && mv routes        app/Routes




  # package.json
  if grep -q 'z_database/import.php' package.json; then
      sed -i 's#z_database/import.php#app/Database/import.php#' package.json
  fi


  # Update the root index.php
  if grep -q '\$z_framework[[:space:]]*->[[:space:]]*execute' index.php; then
      sed -i -E 's/\$z_framework[[:space:]]*->[[:space:]]*execute[[:space:]]*\([[:space:]]*\)[[:space:]]*;/\$z_framework->handleRequest();/g' index.php
  fi




  # Webroot
  mkdir -p webroot




  # .htaccess
  [ -f webroot/.htaccess ] && rm webroot/.htaccess
  touch webroot/.htaccess
  cat > webroot/.htaccess << 'EOF'
  RewriteEngine On 
  RewriteCond %{REQUEST_FILENAME} !-f 
  RewriteRule . index.php [L,QSA]
  EOF

  [ -f .htaccess ] && rm .htaccess




  # Move all public files to webroot by excluding certain files and folders
  EXCLUDE=(
    app
    webroot
    z_framework _framework
    .vscode
    node_modules
    package.json package-lock.json
    composer.json composer.lock composer.local.json
    .dockerignore Dockerfile
    .htaccess 
    .z_framework
    index.php
    .drone.yml
    .gitignore .git
    z_config
    vendor
    Validator helper
    packaging
    tests
    libs
    TODO
    sql.log
    README.md
    LICENSE
    src source
    examples example
  )


  for item in *; do
    if [[ " ${EXCLUDE[*]} " =~ " $item " ]]; then
      continue
    fi

    mv -v "$item" "webroot"
  done




  # Create index.php in webroot
  [ -f webroot/index.php ] && rm webroot/index.php
  touch webroot/index.php

  cat > webroot/index.php << 'EOF'
  <?php

      // -----------------------------
      // Do not change this file as it is the entrypoint for web requests.
      // -----------------------------

      chdir(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);

      // Try multiple locations for the entry scripts
      $entryScripts = [
          "index.php",
          "zubzet.php",
          "zubzet",
      ];

      $entryScriptFound = false;

      foreach($entryScripts as $entryScript) {
          if(!file_exists($entryScript)) break;

          require_once $entryScript;
          $entryScriptFound = true;
      }

      // If no entry script is found, return a 500 error
      if(!$entryScriptFound) {
          http_response_code(500);
          echo "No entry script found.";
          exit(1);
      }

  ?>
EOF

echo "Done."