Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

320
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda