Skip to content

feat: add vendor symlink in WEBDIR for Composer autoload compatibility#1227

Merged
ramonskie merged 1 commit intomasterfrom
feat/composer-vendor-symlink
Feb 25, 2026
Merged

feat: add vendor symlink in WEBDIR for Composer autoload compatibility#1227
ramonskie merged 1 commit intomasterfrom
feat/composer-vendor-symlink

Conversation

@ramonskie
Copy link
Contributor

Summary

Creates a htdocs/vendor -> ../lib/vendor symlink during Composer installation so apps can reference vendor/autoload.php from their web root while keeping the actual vendor directory outside the web root for security.

Problem

Apps using a custom vendor-dir (e.g. lib/vendor) and referencing require 'vendor/autoload.php' from the web root (e.g. htdocs/) would fail because the vendor directory is not accessible relative to htdocs.

Solution

After Composer installation, create a symlink WEBDIR/vendor -> ../lib/vendor when:

  • WEBDIR exists (e.g. htdocs directory)
  • Vendor directory is not already inside WEBDIR
  • No existing vendor directory or symlink in WEBDIR
  • Actual vendor directory exists after Composer installation

Changes

  • src/php/extensions/composer/composer.go — add symlink creation logic after install
  • Fix placeholder syntax: #{LIBDIR}@{LIBDIR} to match unified @{VAR} syntax

Testing

Existing Composer integration tests continue to pass.

Create a symlink from WEBDIR/vendor to the actual vendor directory during
Composer compilation. This allows apps to use relative require paths like
`require 'vendor/autoload.php'` from their web root (e.g., htdocs).

The symlink is only created when:
- WEBDIR exists (e.g., htdocs directory)
- Vendor directory is not already inside WEBDIR
- No existing vendor directory or symlink exists in WEBDIR
- Actual vendor directory exists after Composer installation

Example: If composer.json specifies vendor-dir as "lib/vendor" and WEBDIR is
"htdocs", this creates htdocs/vendor -> ../lib/vendor

This maintains backward compatibility for apps that reference vendor/autoload.php
from their web-accessible directory while keeping the actual vendor directory
outside the web root for security.

Also fixes placeholder syntax: #{LIBDIR} -> @{LIBDIR} to match the unified
@{VAR} syntax used throughout the buildpack.
@ramonskie ramonskie merged commit a18ab05 into master Feb 25, 2026
7 of 13 checks passed
@ramonskie ramonskie deleted the feat/composer-vendor-symlink branch February 25, 2026 17:38
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

Successfully merging this pull request may close these issues.

1 participant