facebook / facebook/capi-param-builder

PHP library is not PSR-4 compliant, autoloading doesn't work

Open Beginner friendly
#33 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
33
Forks
9
PR merge metrics
No merged PRs in 30d

Description

The `composer.json` currently states this:

```php
"autoload": {
"psr-4": {
"FacebookAds\\": "php/capi-param-builder/src/"
}
},
```

Similarly, the `composer.json` within `php/capi-param-builder/php` states this:

```
"autoload": {
"psr-4": {
"FacebookAds\\": "src/"
}
```

The issue is with the classes within the subfolders of the PHP package (`model`, `piiUtil`, `util`) which all use `FacebookAds` namespace. The PSR-4 autoloading won't match them. Any attempt to use one of these classes ends up with straight PHP error, for example:

```
Class "FacebookAds\PII_DATA_TYPE" not found
```

Because of this, our conversion tracking is failing. The Business SDK library is using it exactly this way and fails: https://github.com/facebook/facebook-php-business-sdk/blob/main/src/FacebookAds/Object/ServerSide/UserData.php#L936

Please verify the correctness of autoloading and either update `composer.json` files, or move files out of their subfolders so they match PSR-4 standard.

Thanks!

Contributor guide

Open the contributing guide

Research direction

Inspect the root composer.json and php/capi-param-builder/php/composer.json, then compare their PSR-4 mappings with the namespaces and paths under php/capi-param-builder/src/, especially model, piiUtil, and util. Regenerate Composer autoloading and verify that classes such as FacebookAds\PII_DATA_TYPE can be loaded by the Business SDK usage described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.