Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

318
Views
Twig 1.x - what files can I safely remove for production?

Following an audit, I've been tasked to remove extraneous files from the Twig 1.x vendor directory in one of our sites. Planning on removing /twig/twig/doc, /twig/twig/test and see if anything breaks.

What about /twig/twig/ext/twig/run-tests.php, or the entire "ext" directory?

Does anyone have prior experience weeding a default Twig 1.x installation for production environments? Any assistance or advice gratefully welcomed.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

The correct action would be to update your site's layout so that these files are outside your web server's document root -- then you don't have to worry about what to delete and what to leave. You probably have something like this, where your web server's document root is pointing directly at /path/to/project:

/path/to/project
    /lib
        foo.php
        bar.php
    /twig
        /twig
            /doc
            /test
    index.php

This means anybody can directly request http://yourdomain.com/twig/twig/test/some_file.php

What you want is more like this:

/path/to/project
    /public
        index.php
    /lib
        foo.php
        bar.php
    /twig
        /twig
            /doc
            /test

Then configure your web server so that its document root is /path/to/project/public. Then your application code can still include() things in /twig and /lib, but your web server won't directly serve them.

over 4 years ago · Santiago Trujillo Report

0

If your removing files from the vendor directory they'll come back the next time you do a composer install so this seems kind of pointless.

The files you mention (docs and test) are causing no harm other than taking up space as they are not directly called, but that's just a downside to any package management system. Like @Alex said as long as they are not publicly accessible there is no need to worry.

If you really want Twig without the extra files you could fork the project, move it into your own Git repo then reference that in your composer.json instead of the official one - but you will miss out on any updates from Twig.

over 4 years ago · Santiago Trujillo Report

0

We're running on Apache, so the easiest solution was to simply add a .htaccess file to the top vendor directory:

# Prevent non-local access to the vendor directory.
Order deny,allow
Deny from all

Directory structure:

/root
    /vendor
        .htaccess
        /twig
        ...
    /includes
        ...

Now the PHP scripts continue to have access, but external attempts to view anything inside the vendor directory return a 403 error.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!