Task: Investigate Composer / Packagist / PSR-4 Modules in Trongate v2
I would like to create a page of documentation for the Trongate framework explaining how developers can create Trongate modules that work with Composer, Packagist and PSR-4 autoloading.
This work will be carried out in two phases.
Phase 1 - Investigation
Grady is responsible for this phase.
Your job is to investigate the subject thoroughly and get a very basic working example running against the latest version of Trongate v2.
Do not attempt to write the final polished documentation. Instead, document your findings clearly so that another agent can use your notes to produce the final documentation later.
Useful reference
There is an existing YouTube video covering this subject:
https://www.youtube.com/watch?v=oVSDrG4ibrI
However, this video was produced for Trongate v1.
Please watch/review it where possible and determine which parts of the process remain applicable to Trongate v2 and which parts need to be changed.
Do not assume that the v1 process is still correct. Verify everything against the current v2 framework.
What needs to be investigated
Determine how a developer can create a basic Trongate v2 module that:
- Exists within a normal Trongate v2 application.
- Uses Composer for dependency management.
- Can use a third-party package installed through Composer.
- Uses PSR-4 autoloading where appropriate.
- Can potentially be distributed through Packagist.
- Can be loaded and used correctly by a Trongate module.
- Works correctly with the current Trongate v2 directory structure and bootstrap process.
Investigate the relationship between the Trongate framework's own autoloading mechanism and Composer's autoloader.
In particular, establish exactly where and how Composer's autoloader needs to be loaded, if it needs to be loaded explicitly at all.
use statements
Pay particular attention to the possibility of using PHP use statements within Trongate classes.
For example:
<?php
use Aws\CloudFront\CloudFrontClient;
class Training extends Trongate {
Determine whether this approach works correctly in Trongate v2 and, if so, document the exact circumstances and requirements.
Do not assume that simply adding a use statement is sufficient. Verify the complete process, including Composer installation, autoloading and framework execution.
Starter example
Create the simplest possible working example that demonstrates the concept.
The example should preferably use a real Composer package rather than a completely artificial package.
The objective is not to build a sophisticated module. We want a minimal proof of concept that demonstrates:
Trongate v2 module → Composer → PSR-4 autoloading → third-party PHP class/package → successful execution.
Record the exact steps required to reproduce the example.
Where appropriate, record:
- Directory structure.
composer.json contents.
- Composer commands used.
- Namespace declarations.
use statements.
- Any changes required within the Trongate application.
- Any changes required within the module.
- How the module was accessed/tested.
- Expected output.
- Any errors encountered and how they were resolved.
Packagist investigation
Also investigate what would be required for a Trongate module to become a Composer package that could be published to Packagist.
Establish the distinction between:
- A Trongate module using a Composer package.
- A Trongate module being distributed as a Composer package.
- A package being registered on Packagist.
Do not over-engineer this phase. The immediate objective is to understand the basic mechanism and establish a reliable starter example.
Important: use the current framework
Use the latest Trongate v2 codebase for all testing.
Do not make assumptions based solely on Trongate v1.
If the v1 YouTube video demonstrates a technique that no longer applies, explicitly record that.
Likewise, if the v1 technique still works in v2, record that and explain why.
Record your findings
Create a clear investigation report/page containing all findings.
The report should include:
- What works
- What does not work
- What has changed from v1
- The working starter example
- Required directory structure
- Required Composer configuration
- Required PHP namespaces /
use statements
- How Composer's autoloader interacts with Trongate
- How a module could potentially be packaged for Packagist
- Any limitations, caveats or unresolved questions
Include the actual code used to prove the concept.
The report does not need to be beautifully written. Accuracy and reproducibility are more important at this stage.
Phase 1 deliverable
The final deliverable from Grady should be a technical investigation report, not the finished public-facing documentation.
Once this investigation is complete, I will ask Mike to use Grady's findings to write the actual Trongate framework documentation page.
Do not make unnecessary changes to the Trongate framework itself.
The goal of this phase is to understand the process, prove it works with Trongate v2, and leave Mike with enough accurate information to produce the final documentation.
Task: Investigate Composer / Packagist / PSR-4 Modules in Trongate v2
I would like to create a page of documentation for the Trongate framework explaining how developers can create Trongate modules that work with Composer, Packagist and PSR-4 autoloading.
This work will be carried out in two phases.
Phase 1 - Investigation
Grady is responsible for this phase.
Your job is to investigate the subject thoroughly and get a very basic working example running against the latest version of Trongate v2.
Do not attempt to write the final polished documentation. Instead, document your findings clearly so that another agent can use your notes to produce the final documentation later.
Useful reference
There is an existing YouTube video covering this subject:
https://www.youtube.com/watch?v=oVSDrG4ibrI
However, this video was produced for Trongate v1.
Please watch/review it where possible and determine which parts of the process remain applicable to Trongate v2 and which parts need to be changed.
Do not assume that the v1 process is still correct. Verify everything against the current v2 framework.
What needs to be investigated
Determine how a developer can create a basic Trongate v2 module that:
Investigate the relationship between the Trongate framework's own autoloading mechanism and Composer's autoloader.
In particular, establish exactly where and how Composer's autoloader needs to be loaded, if it needs to be loaded explicitly at all.
usestatementsPay particular attention to the possibility of using PHP
usestatements within Trongate classes.For example:
Determine whether this approach works correctly in Trongate v2 and, if so, document the exact circumstances and requirements.
Do not assume that simply adding a
usestatement is sufficient. Verify the complete process, including Composer installation, autoloading and framework execution.Starter example
Create the simplest possible working example that demonstrates the concept.
The example should preferably use a real Composer package rather than a completely artificial package.
The objective is not to build a sophisticated module. We want a minimal proof of concept that demonstrates:
Trongate v2 module → Composer → PSR-4 autoloading → third-party PHP class/package → successful execution.
Record the exact steps required to reproduce the example.
Where appropriate, record:
composer.jsoncontents.usestatements.Packagist investigation
Also investigate what would be required for a Trongate module to become a Composer package that could be published to Packagist.
Establish the distinction between:
Do not over-engineer this phase. The immediate objective is to understand the basic mechanism and establish a reliable starter example.
Important: use the current framework
Use the latest Trongate v2 codebase for all testing.
Do not make assumptions based solely on Trongate v1.
If the v1 YouTube video demonstrates a technique that no longer applies, explicitly record that.
Likewise, if the v1 technique still works in v2, record that and explain why.
Record your findings
Create a clear investigation report/page containing all findings.
The report should include:
usestatementsInclude the actual code used to prove the concept.
The report does not need to be beautifully written. Accuracy and reproducibility are more important at this stage.
Phase 1 deliverable
The final deliverable from Grady should be a technical investigation report, not the finished public-facing documentation.
Once this investigation is complete, I will ask Mike to use Grady's findings to write the actual Trongate framework documentation page.
Do not make unnecessary changes to the Trongate framework itself.
The goal of this phase is to understand the process, prove it works with Trongate v2, and leave Mike with enough accurate information to produce the final documentation.