Monday, January 24, 2022

[FIXED] Composer.json in a simple PHP

Issue

I knew this is so basic question but I completely have no idea how to deal with this. I have a single PHP page that contain a form and simple PHP code to insert form data to database.

Now I want to test a Composer based code Code Link

I just simply copy this entire code and try to run but it shows syntax error. Yes I already installed composer.json

charge-credit-card.php is the file that I just created as mention on github enter image description here

My problem is not this code I want to learn how I run any Composer based code without any framework. Just simple way to test any code.


Solution

If you want to learn how to use Composer have a look at tutorials like this:
https://www.dev-metal.com/composer-tutorial/

The key is to require Composer's autoload.php in your own main project file (e.g. in your index.php).

<?php

require 'vendor/autoload.php';

This loads the Composer autoloader. So this line includes everything that Composer has downloaded into the project.



Answered By - Pᴇʜ

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.