I am trying to use jeroendesloovere VCARD in Codeigniter 3 controller as below:
public function get_contact($unique_id)
{
namespace JeroenDesloovere\VCard\VCard;
require_once 'vendor/behat/transliterator/src/Behat/Transliterator/Transliterator.php';
require_once 'vendor/jeroendesloovere/vcard/src/VCard.php';
$vcardObj = new VCard();
$status_db_customers['data']=$this->Site_model->get_customer_QR($unique_id);
foreach ($data as $row){
$vcardObj->addName($row->first_name. " " . $row->first_name);
$vcardObj->addBirthday($contactResult[0]["date_of_birth"]);
$vcardObj->addEmail($row->email);
$vcardObj->addPhoneNumber($row->mobile);
$vcardObj->addAddress($row->add_line_1);
}
return $vcardObj->download();
}
But this always gives an error.
Message: syntax error, unexpected token "namespace"
Please help me on how to use this ? This is inside my controller class.
Your controller should look like this:
Also make sure you've set up CodeIgniter to use Composer's autoloading file. For this you need to set
$config['composer_autoload']inapplication/config.php, depending on where Composer'svendorfolder is:If the
vendorfolder is inside theapplicationfolder, set it toTRUE:$config['composer_autoload'] = TRUE;Or if the
vendorfolder is at a different location, specify it's path.For example, if the
vendorfolder is at the same level as theapplicationfolder, set it tovendor/autoload.php:$config['composer_autoload'] = 'vendor/autoload.php';