Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

315
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda