In the last topic, I explained how Symfony bundles, recipes, and configuration files integrate into your project. Now let's look at how to manage these same bundles inside PHPMaker, and how to keep your setup consistent — even after regeneration.
PHPMaker provides flexible ways to install Symfony bundles, register them, and preserve configuration across regenerations. The following explains the recommended workflow for adding both official Symfony bundles and third‑party bundles in PHPMaker projects.
1. Add Packages Using Tools → Composer Packages
PHPMaker includes a built‑in Composer Packages tool under:
Tools → Composer Packages
Use this tool to install Symfony or third‑party Composer packages such as:
- symfony/ux-icons
- any other bundle your project needs
PHPMaker updates composer.json and runs Composer automatically when generating the project.
2. Automatic Bundle Registration for Symfony Packages
PHPMaker recognizes many official Symfony packages and can register their bundles automatically in config/bundles.php.
This applies to Symfony bundles like Symfony\UX\Icons\UXIconsBundle.
No extra coding is required — PHPMaker adds the bundle when the package is installed.
3. Adding Third‑Party Bundles Manually
If a third-party package is not automatically recognized as a Symfony bundle, you can add it manually using User Code in your project, e.g.
AddComposerPackage(
'symfony/ux-icons',
'^2.31.0',
'Symfony\\UX\\Icons\\UXIconsBundle',
{ all: true }
);
This command:
- Adds the Composer package
- Registers the bundle
- Ensures it loads in all environments (dev, prod)
Use this method for any third‑party Symfony bundle that PHPMaker does not detect.
4. Saving Bundle Configuration Files
Most bundles need configuration (e.g. config/packages/ux_icons.yaml). To ensure these files persist after regeneration, add them through Custom Files.
For example, you can add the configuration file of the bundle:
- File name should be
ux_icons.yamlorux_icons.php, - No need to enter Caption, which is not applicable,
- Do not enable Include Common Files,
- Path should be
config/packages
Repeat for other files. PHPMaker will copy these files into the output project every time you regenerate so they will remain intact across all builds.
5. Reusing the Setup Across Projects
Custom Files is ideal when you only need to add one or two configuration files. PHPMaker will copy these files into the output project on every regeneration, which works well for simple setups.
However, if you need to include many files, such as multiple config files, classes, assets, then managing everything through Custom Files becomes cumbersome. In these cases, it is better to package your setup into a PHPMaker extension.
An extension allows you to:
- include many files in an organized way (add
<control>tags to the extension's XML file) - install Composer packages (use
AddComposerPackage()in theindex.jsof the extension) - register Symfony bundles
- create configuration files
- apply recipe-related adjustments
And importantly, if you plan to reuse the same bundles and configuration across multiple PHPMaker projects, packaging everything into an extension is the best long-term solution.
See Making Extensions for details.