# Create the Build to Prefix the Joomla 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/updates) them for you. For more information about Composer, please, visit https://getcomposer.org/ (opens new window).
# Prefixing the "Hello Prefixed World module" Project
In this guide, we will prefix the project "Hello Prefixed World Module". We will prefix it with our prefix PPP
.
The source code of the project can be found in this repository: https://github.com/PHP-Prefixer/hello-joomla-world (opens new window)
The results of the prefixing process can be found in this repository: https://github.com/PHP-Prefixer/hello-joomla-world_prefixed (opens new window)
# The "Hello Prefixed World Module" Project
The modified version of the Hello World module shows a formatted date before the "Hello, World!" message src\Helper.php
:
<?php
/**
* @package Hello Prefixed World for Joomla
* @version 1.0.0
*/
namespace ModHelloWorld;
// No direct access
defined('_JEXEC') or die;
use Carbon\Carbon;
class Helper
{
/**
* Retrieves the hello message
*
* @param array $params An object containing the module parameters
*
* @access public
*/
public static function getHello($params)
{
$now = Carbon::now();
$formattedDate = $now->toDateTimeString();
return $formattedDate.' / Hello, World!';
}
}
# 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 Joomla",
"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:
- Download the source code from the repository.
- Go to the project directory.
- 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 into 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.
- Go to "Project."
- Click on "Create Build."
- Select the file to be prefixed.
- Upload and create the build; click on "Create Build."
# Validating the Build
Once the build is created, the PHP-Prefixer service automatically validates the project and continues with the next steps.
# Prefixing the Build
Once the build is validated, the PHP-Prefixer service prefixes the files and notifies when processing is completed.
Congratulations, you’ve prefixed your "Hello Prefixed World Module" for the Joomla project!