Did any one try running composer in OC 4.0 ?
https://code.tutsplus.com/tutorials/int ... -cms-27874
This article did composer with OC3.x successfully
I noticed that after OC4.0
There is no require_once(DIR_STORAGE . 'vendor/autoload.php'); in system/startup.php
and there is a new file system/vendor.php
I could do composer require , but i cannot use class in Controller Layer
either I add related autoload code in system/vendor.php or not .
It shows Class "xxxxxxxxxxxxxxxxxx" not found
https://code.tutsplus.com/tutorials/int ... -cms-27874
This article did composer with OC3.x successfully
I noticed that after OC4.0
There is no require_once(DIR_STORAGE . 'vendor/autoload.php'); in system/startup.php
and there is a new file system/vendor.php
I could do composer require , but i cannot use class in Controller Layer
either I add related autoload code in system/vendor.php or not .
It shows Class "xxxxxxxxxxxxxxxxxx" not found
Class "xxxxxxxxxxxxxxxxxx" not found
means you need to install the not-found php component on your server via ssh and after install the php component, you need to restart php or your server.
the errors means something wrong with your server.
means you need to install the not-found php component on your server via ssh and after install the php component, you need to restart php or your server.
the errors means something wrong with your server.
https://www.ectransistors.com/
https://www.transistormosfet.com/
thanks for this, id found the composer vendor folder in storage and wondered if i could use it, installed my library with require , added use lines to the class but class not found when trying to new() in .... thank you thankyou , just edit system/vendor maybe oc should just autoload ?? (chongshengdz you are way off, delete your post)
Go to your system/storage folder, where you will find the 'composer.json' file, which can be edited, to add your needed package. Then run a 'composer update' from your command prompt.haydent wrote: ↑Fri Jun 30, 2023 1:43 pmthanks for this, id found the composer vendor folder in storage and wondered if i could use it, installed my library with require , added use lines to the class but class not found when trying to new() in .... thank you thankyou , just edit system/vendor maybe oc should just autoload ?? (chongshengdz you are way off, delete your post)
Having said that, it might be better to leave this alone, and create your own OpenCart 4 extension, e.g. something like this, all wrapped up in an .ocmod.zip archive:
myext/system/library/mymod/vendor/*
myext/system/library/mymod/composer.json
myext/system/library/mymod/composer.lock
And then use it in your OpenCart extension via PHP's require or include.
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
I did that (update composer.json or use require command) but you still have to edit vendor.php which is a pain and seems pointless when there is a perfectly good autoloader available, plus its not just the lib you want, its all its dependencies, plus their functions....
I tried creating a 2nd vendor/composer install but this doesnt work as common dependency libraries will conflict, ie you cant run 2 copies of guzzle...
I tried creating a 2nd vendor/composer install but this doesnt work as common dependency libraries will conflict, ie you cant run 2 copies of guzzle...
You need to include the vendor/autoload.php. E.g. this is how I did it for the Export/Import tool:
Code: Select all
....
// enable auto_load from system/library/export_import
require( DIR_EXTENSION.'export_import/system/library/export_import/vendor/autoload.php' );
// Use the PhoOffice/PhpSpreadsheet package from https://github.com/PHPOffice/PhpSpreadsheet
$workbook = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
....
Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig
actually this is how ive done it in the past, so no big deal, what i was talking about is using the system composer install, but i think it retrospect its likely best to run my own composer install.
Yeah - ugh - that vendor.php is ugly and the composer.json is broken in v4 (running composer update in the storage directory on a vanilla install fails due to a conflict between phpdocumentor and twig and guzzlehttp/promises changes in >v3 and no longer includes the functions_include.php file)
I found a solution for the phpdocumentor problem by changing the require line to load the shim instead. But the rest of that file is just janky. I found if you comment out all the references to vendor and just use the composer autoloader (require_once) it seems to work just fine. vendor.php might still be useful for loading non composer / packagist libraries, but is there some reason they do it this way? That's just bleh!
Read more about here: viewtopic.php?p=867361#p867361
I found a solution for the phpdocumentor problem by changing the require line to load the shim instead. But the rest of that file is just janky. I found if you comment out all the references to vendor and just use the composer autoloader (require_once) it seems to work just fine. vendor.php might still be useful for loading non composer / packagist libraries, but is there some reason they do it this way? That's just bleh!
Read more about here: viewtopic.php?p=867361#p867361
Who is online
Users browsing this forum: No registered users and 7 guests