Forum Moderators: coopster

Message Too Old, No Replies

Installing Composer and composer.json inside WordPress theme

         

toplisek

8:28 am on May 12, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I try to install composer inside a WordPress theme.
Need help how to manage composer.json and where it should be placed to manage links inside WordPress pages.

Steps to be followed:

we install composer and it is outside WordPress public_html folder.
composer.JSON will be inside a root directory besides composer-LOCK
create a vendor directory inside a root directory and place a file called autoload.php inside the vendor directory.
we initialize components:


require_once ROOT_DIR . "vendor/autoload.php";
//use Twilio\Rest\Client;


Please inform me if this will work or PHP code need modifications?
Where (file) we place PHP code?

phranque

9:51 pm on May 15, 2023 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



the PHP code should be in your functions.php which is loaded by WP when the theme is activated.

toplisek

1:52 pm on Sep 13, 2023 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank you for the message.

TessCompton

9:53 am on Sep 14, 2023 (gmt 0)



Sure thing! Your setup seems on the right track. Just make sure the PHP code you wrote is placed in the appropriate WordPress theme file, depending on where you want it to run. It should work well!