Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class "Twig\TwigTest" Not Found When Using Repack Command to Create PHAR #600

Open
arnolem opened this issue Jan 9, 2025 · 1 comment
Open

Comments

@arnolem
Copy link
Contributor

arnolem commented Jan 9, 2025

Hello,

I am working on a project that uses Twig for templating. Everything works perfectly during development. However, when I use the repack command to create a PHAR, I encounter the following error when i exectur command:

In CoreExtension.php line 295:
Class "Twig\TwigTest" not found

After investigating, it seems that the class Twig\TwigTest is being removed from the vendor directory during the repackaging process. This might be because the class name (TwigTest) is mistaken for an unnecessary file and excluded during the PHAR creation.
Unfortunately, this class is essential for Twig to function properly, and its absence causes the error above when the PHAR is executed.

Steps to Reproduce:

Create a project using Twig for templating.
Run the repack command to build a PHAR.
Attempt to execute the PHAR.
Observe the error: Class "Twig\TwigTest" not found.
@arnolem
Copy link
Contributor Author

arnolem commented Jan 9, 2025

I found a workaround by adding a box.json file containing:

{
  "blacklist": [
    "Test",
    "box.json"
  ],
  "files": [
    "vendor/twig/twig/src/TwigTest.php"
  ]
}

However, the problem comes from the original configuration file, which excludes too many things:

{
  "base-path": "../../",
  "files-bin": [
    "tools/watcher/bin/watcher-linux-amd64"
  ],
  "blacklist": [
    "castor",
    "Test",
    "tools",
    "vendor/symfony/http-foundation",
    ".exe",
    ".dll"
  ],
  "compactors": [
    "KevinGH\\Box\\Compactor\\Php"
  ],
  "annotations": false,
  "compression": "GZ",
  "check-requirements": false,
  "main": "bin/castor",
  "output": "tools/phar/build/castor.linux-amd64.phar"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant