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

Strauss does not remove namespaced classes from the composer classmap files when optimize-autoloader is enabled #87

Closed
estevao90 opened this issue Mar 5, 2024 · 2 comments

Comments

@estevao90
Copy link

When we have any namespaced class, and we use the optimize-autoloader (e.g., composer install --no-dev --optimize-autoloader ), Strauss does not remove moved files entries from the vendor/composer/autoload_classmap.php and vendor/composer/autoload_static.php files.

Example:

{
	"require": {
		"psr/container": "^1.1"
	},
	"extra": {
		"strauss": {
			"target_directory": "vendor-prefixed",
			"classmap_prefix": "Class_Prefix_",
			"constant_prefix": "Constant_",
			"namespace_prefix": "New\\Namespace",
			"delete_vendor_files": true,
			"packages": [
				"psr/container"
			]
		}
	},
	"scripts": {
		"strauss": [
			"[ -f ./strauss.phar ] || curl -o strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/download/0.16.0/strauss.phar",
			"@php strauss.phar"
		],
		"post-install-cmd": [
			"@strauss"
		],
		"post-update-cmd": [
			"@strauss"
		]
	}
}

When we run composer install and check the vendor/composer/autoload_classmap.php, this file doesn't contain the psr files entries.

However, if we delete the vendor/vendor-prefixed folders and run it again using the optimized version (composer install -o), the psr files are there:

See:

<?php

// autoload_classmap.php @generated by Composer

$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
    'Psr\\Container\\ContainerExceptionInterface' => $vendorDir . '/psr/container/src/ContainerExceptionInterface.php',
    'Psr\\Container\\ContainerInterface' => $vendorDir . '/psr/container/src/ContainerInterface.php',
    'Psr\\Container\\NotFoundExceptionInterface' => $vendorDir . '/psr/container/src/NotFoundExceptionInterface.php',
);

Same case for the vendor/composer/autoload_static.php file.

@BrianHenryIE
Copy link
Owner

Yeah, makes sense. See #34, #81, #69 and 4e1a9b6 for related issues/fixes. Thanks for reporting it.

@BrianHenryIE
Copy link
Owner

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

2 participants