You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for this amazing tool, it works perfectly and helps me decrease the size of my lambda funtions on aws.
In a Symfony project and on a dev evironment it works like a charm but on prod I get the error symfony prod Cannot declare class because the name is already in use in
My .vendor_compress file is :
<?php
declare(strict_types=1);
use Donatorsky\VendorCompress\Config;
use Donatorsky\VendorCompress\FileFilters\BasenameFilter;
use Donatorsky\VendorCompress\FileFilters\BasenameRegexFilter;
use Donatorsky\VendorCompress\FileFilters\ExtensionFilter;
use Donatorsky\VendorCompress\FileFilters\IsDirectoryFilter;
use Donatorsky\VendorCompress\FileFilters\IsFileFilter;
use Donatorsky\VendorCompress\FileFilters\VendorPackageFilter;
use Donatorsky\VendorCompress\FileProcessors\MinifyJsonFileProcessor;
use Donatorsky\VendorCompress\FileProcessors\StripWhitespacesPhpFileProcessor;
return Config::create()
->setFilesCompressionMethod(Phar::NONE)
->setArchiveCompressionMethod(Phar::NONE)
->setExcluded([
new VendorPackageFilter('donatorsky', 'vendor-compress'),
new IsDirectoryFilter(new BasenameFilter('docs')),
new IsDirectoryFilter(new BasenameFilter('tests')),
//new IsDirectoryFilter(new BasenameFilter('src')),
//new IsDirectoryFilter(new BasenameFilter('public')),
//new IsDirectoryFilter(new BasenameFilter('config')),
new IsFileFilter(new BasenameFilter('composer.json')),
new IsFileFilter(new BasenameFilter('composer.lock')),
new IsFileFilter(new BasenameFilter('.gitignore')),
new IsFileFilter(new BasenameRegexFilter('/^(?:README|CHANGELOG|phpunit.*\.xml.*$)/i')),
])
//->addFileProcessor(new MinifyJsonFileProcessor(), new ExtensionFilter('json'))
//->addFileProcessor(new StripWhitespacesPhpFileProcessor(), new ExtensionFilter('php'))
;
I had to disable json minification due to a different error but it's okay.
I thought this autoloading duplicates was caused but the StripWhitespacesPhpFileProcessor but disabling it didn't solve the issue on prod ..
Any idea ? I would really love to use this tool but until now I can't since it's broken on prod evironment
PS: when I say "prod" I mean the environment state within my symfony project.
Thank you !
The text was updated successfully, but these errors were encountered:
Happy to see that You are using this tool! It's going to be quite hard to find a solution for that without accessing Your project and playing with it and Vendor Compress, but I understand it may be impossible for You to share it.
A couple of thoughts on this:
The Cannot declare class because the name is already in use error occurs when some file is included/required more than once, but it shouldn't be. Most probably, there is some include_once/require_once call which tries to load file, thus disabling filters won't help.
Originally, this project was created to work with Composer v1, and it was not updated since the release of v2. The autoloading may have changed, and as Vendor Compress works by modifying these autoloading files, I see this as a potential root cause of the problem.
By dev or prod You probably mean different environment configurations and project building conditions. I suppose there are some differences in building process, different composer install flags, perhaps. It is a good practise to enable --optimize-autoloader or --classmap-authoritative options when preparing production build. You can try disabling them (or their combination) for now, but it may affect the performance of Your application.
I'll look into this more thoroughly and configure it in my projects in a spare time, but it certainly won't happen in the next week... Sorry for that!
Anyway, thanks for Your feedback, and apologies for not helping You more! I will let You know when I find a solution.
BTW,
Regarding a compression issues, I noticed, that Phars with archive compression are not always working correctly. Try enabling files compression only. I remember that Phar::GZ was working for me.
Hi,
Thank you for this amazing tool, it works perfectly and helps me decrease the size of my lambda funtions on aws.
In a Symfony project and on a dev evironment it works like a charm but on prod I get the error symfony prod Cannot declare class because the name is already in use in
My .vendor_compress file is :
I had to disable json minification due to a different error but it's okay.
I thought this autoloading duplicates was caused but the StripWhitespacesPhpFileProcessor but disabling it didn't solve the issue on prod ..
Any idea ? I would really love to use this tool but until now I can't since it's broken on prod evironment
PS: when I say "prod" I mean the environment state within my symfony project.
Thank you !
The text was updated successfully, but these errors were encountered: