Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to use the invoice generator from webchemistry. I installed this with composer require webchemistry/invoice:^1.0.

I moved this folder to my APPPATH . 'third_partyvendor'; folder. So in my config file I have the following line:

$config['composer_autoload'] = APPPATH . 'third_partyvendorautoload.php';

my index.php file (in root) contains this code:

include_once BASEPATH.'../application/third_party/vendor/autoload.php';

In my controller I am trying to do the following :

public function createInvoice()
{
    $company = new WebChemistryInvoiceDataCompany();
}

This results in the following error:

Message: Class 'WebChemistryInvoiceDataCompany' not found

When in my IDE (PhpStorm) I ctrl + click on Company, it can resolve correctly and points to the correct file. Why can PHP not resolve this to the correct file location?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
793 views
Welcome To Ask or Share your Answers For Others

1 Answer

add the file include and following code in your controller at the start

$config['composer_autoload'] = false; // no need change this, make it default

<?php
require_once(APPPATH . '/third_party/vendor/autoload.php');
use WebChemistryInvoiceDataCompany as Company;

class Invoice extends CI_Controller {

    public function createInvoice(){
        $company = new Company();
    }

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...