Comments (13)
If it is helpful for anyone, what I did to fix this in our implementations, was to apply a patch to the library using composer-patches. The patch simply removes the autoload line.
However, this did not completely resolve the issues for me. I also had to use a condition to selectively change the autoload path in spl_autoload_register
& then finally include the ET_Client.php file.
...
spl_autoload_register( function($class_name) {
if (strpos($class_name, 'ET_') === 0) {
include_once __DIR__ . '../vendor/salesforce-mc/fuel-sdk-php/src/'.$class_name.'.php';
}
});
require '../vendor/salesforce-mc/fuel-sdk-php/src/ET_Client.php';
Hope this helps some people in the meantime.
from fuelsdk-php.
If you follow the demo provided, it starts with this autoload function
spl_autoload_register(function($class_name) {
include_once __DIR__ . '/path/to/src/' . $class_name . '.php';
});
that will automatically load the necessary classes for the library when you call them
from fuelsdk-php.
@jlillyreed What demo are you referring to? Please provide a link.
from fuelsdk-php.
@embolden https://github.com/salesforce-marketingcloud/FuelSDK-PHP/blob/master/objsamples/sample-list.php
from fuelsdk-php.
@embolden Any luck solving this? Up against exact same issue. Autoload didn't work, so I added it into my composer.json. Now it loads, but cannot find autoload.php at the location it is hardcoded to get it from in ET_Client.php on line 2.
Doing the method mentioned by jillyreed ends in the same issue with
from fuelsdk-php.
I am also having issues with the autoloader. On the previous version (0.9) I could access the classes from the global namespace like this \ET_Client()
.
I upgraded from 0.9 to 1.0 and now those classes cannot be found. I have added
spl_autoload_register(function($class_name) {
include_once __DIR__ . '/../../vendor/salesforce-mc/fuel-sdk-php/src/' . $class_name . '.php';
});
like @jlillyreed suggested, but that results in an error opening fuel-sdk-php/src/../vendor/autoload.php which does not exist. It exists in the root of the vendor directory, not within the sdk's non-existent vendor directory. Changing the require statement to require __DIR__ . '/../../../autoload.php';
fixes the issue without needing a classmap in the project's composer.json.
It seems like the path that it is using for the autoloader is incorrect. Removing the require statement in ET_Client fixes the issue for me if I add a classmap in my composer.json. I'm not sure I understand how that require statement is expected to work since there should not be a vendor directory inside of the sdk when you install it using composer.
from fuelsdk-php.
I'm having issues as well when I did not have issues on the older version. Using Symfony 2.8 w/ composer.
from fuelsdk-php.
Yeah something is really messed up with autoloading on the latest release. @smunuswami or @sharif26 do you maintain this project? If so: please fix.
from fuelsdk-php.
There seems to be an issue with autoload and we are working on it, should be fixed on next release.
So the work around is to comment to autoload line on ET_Client.php file:
//require __DIR__ . '/../vendor/autoload.php';
If you use composer, just make sure you include vendor/autoload.php properly from wherever you are calling from our(or any) dependency. That will ensure all dependencies to load correctly including ours (change the below path according to your vendor location):
require __DIR__ . '/../vendor/autoload.php';
Now if you are testing/using our unit test cases, the line to add on UnitBootstrap.php is:
require __DIR__ . '/../../../autoload.php';
And to run our test cases:
phpunit --bootstrap tests/UnitBootstrap.php tests/CampaignTest.php
Hope it clarifies & resolves the issue for now.
from fuelsdk-php.
@sharif26 Thanks for the quick response. Does this change need to be done to every single class file in this library? Even after using your fix for ET_Client
I am still getting issues:
Is there an ETA on when the next release will be? I can not and will not use this in a production env. Modifying vendor files is terrible practice. I need this library for a time sensitive project, that is why I ask.
from fuelsdk-php.
You can also just set the version to 0.9.1
until the latest release is fixed. I did this and it is much easier then modifying vendor files (which should be avoided completely on production servers anyways).
Still no ETA on the fix?
from fuelsdk-php.
Please check our new release, autoload issue should be fixed by that. Thanks to all for your helpful code snippet and information.
from fuelsdk-php.
Guys,
I came up with a solution.You should go to your vendor
folder and delete autoload.php
file and rerun php composer.phar update
, it will regenerate new autoload.php
file and you can use FuelSdk normally, and only need to add require __DIR__ . '/vendor/autoload.php';
, nothing else
from fuelsdk-php.
Related Issues (20)
- [BUG] Authentication fails on newly created packages using Legacy authentication HOT 5
- Is there no way to pull from all business units?
- Trying to filter DataExtensions using a Client.ID but we get Filter Property 'Client.ID' is not a retrievable property HOT 10
- "Error: API Permission Failed." in ET_Get.php HOT 2
- [BUG] config.php file is already present in my project HOT 5
- [BUG]
- Triggered Send Attributes? HOT 1
- Adding data for a triggered send HOT 1
- Connecting from a local environment HOT 1
- Unable to validate App Keys(ClientID/ClientSecret) w/ Php 7.4.x [BUG] HOT 3
- ET_GetSupportRest does not support URLProps and MoreResults logic not working HOT 1
- ET_DataExtension_Row extends but does not implement Upserts HOT 1
- [Enhancement] Maintain these packages?
- [undefined array index in ET_Client.php in function getAuthTokenExpiration if $tenantKey and $this->tenantTokens are null] HOT 8
- print_r in ET_Perform
- [BUG] PHP 8: Deprecated function: trim(): Passing null to parameter of type string is deprecated.
- [Enhancement] Support firebase/php-jwt version 6
- [BUG] Trying to access array offset on value of type null in ET_Client.php on line 645
- [BUG] php8.0 or upper
- OAuth error on SOAP request HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fuelsdk-php.