# Create the Build to Prefix the PrestaShop Module

PHP-Prefixer works based on Composer (opens new window) as the dependency management tool. It allows you to declare the libraries your project depends on and manages (install/update) them for you. For more information about Composer, please visit https://getcomposer.org/ (opens new window).

# Prefixing the "Hello PrestaShop Products Module" Project

In this guide, we will prefix the project "Hello PrestaShop Products Module". We prefix it with our prefix PPP.

The source code of the project can be found in this repository: https://github.com/PHP-Prefixer/hello-prestashop-world (opens new window)

The results of the prefixing process can be found in this repository: https://github.com/PHP-Prefixer/hello-prestashop-world_prefixed (opens new window)

# The "Hello PrestaShop Products Module" Project

The modified version of the Hello PrestaShop Products module calls on the Collections library with the PPP prefix src/ProductsCollection.php:

<?php

namespace PsProducts;

use Tightenco\Collect\Support\Collection;

/**
 * Manage a ProductsCollection instead of a collection of Products array.
 */
class ProductsCollection extends Collection
{
}

# The PHP-Prefixer Configuration

In the composer.json schema, in the extra configuration, the PHP-Prefixer configuration is as follows:

    "extra": {
        "php-prefixer": {
            "project-name": "Hello Prefixed World for PrestaShop",
            "namespaces-prefix":: "PPP",
            "global-scope-prefix": "PPP_",

            "exclude-paths": [
                "bin/",
                "doctrine/inflector/docs",
                "voku/portable-ascii/build"
            ]
        }
    }

The configuration declares the project name and the prefix PPP used for namespaces and global objects (functions, etc.).

In particular, this schema has the attribute excludePaths to help package the module for distribution. The excludePaths remove folders that should not be included in the target prefixed module (commands, unit tests, library documentation, etc.).

# Verify Composer.json

To review the project:

  1. Download the source code from the repository.
  2. Go to the project directory.
  3. Run the following command to verify the schema and lock the project's dependencies that would be distributed:
~$ composer update --no-dev
...
Writing lock file
Generating autoload files
...

Then, compress the files in a new ZIP file or download the project's ZIP file from GitHub.

# Create a Build

You can now set up a new build and prefix the project in the "Dashboard/ Projects" area in a matter of minutes. Follow the steps below to set up a build and prefix the project ZIP file.

  1. Go to "Project."
  2. Click on "Create Build."
  3. Select the file to be prefixed.
  4. Upload and create the build; click on "Create Build."

Create a Build

# Validating the Build

Once the Build is created, the PHP-Prefixer service automatically validates the project and continues with the next steps.

Validating the Build

# Prefixing the Build

Once the Build is validated, the PHP-Prefixer service prefixes the files and notifies when processing is completed.

Prefixing the Build

Congratulations, you’ve prefixed your "Hello PrestaShop Products Module" for the PrestaShop project!

Last Updated: 12/19/2023, 9:07:55 AM