I am trying to use the Zend Service Livedocx. I am using two models in my application - Submission and SubmissionFiles. I am saving the Submission data and the SubmissionFiles data with the Create action in the SubmissionController. I am trying to call the MailMerge class in that action but I am getting the error: Fatal error: Cannot redeclare class ZendService\LiveDocx\AbstractLiveDocx in C:\wamp\www\publications\src\web\protected\vendors\ZendService\LiveDocx\AbstractLiveDocx.php
//some code
public function actionCreate()
{
$model=new Submission;
if(isset($_POST['Submission']))
{
$model->attributes=$_POST['Submission'];
if($model->save())
{
$modelFile = new SubmissionFiles;
if(isset($_POST['SubmissionFiles']))
{
Yii::import('application.vendors.zendservice.livedocx.*');
$phpLiveDocx = new MailMerge();
//somecode
<?php
require_once 'ZendService\LiveDocx\AbstractLiveDocx.php';
class MailMerge extends AbstractLiveDocx
{ //somecode
<?php
namespace ZendService\LiveDocx;
use Traversable;
use Zend\Soap\Client as SoapClient;
use Zend\Stdlib\ArrayUtils;
abstract class AbstractLiveDocx
{ //some code
If I comment the require_once 'ZendService\LiveDocx\AbstractLiveDocx.php'; in MailMerge.php, I get the error: Fatal error: Class 'AbstractLiveDocx' not found in C:\wamp\www\publications\src\web\protected\vendors\ZendService\LiveDocx\MailMerge.php
What am I doing wrong?
I guess you are using composer to include Zend as dependancy. If so you must add the autoloader to your index.php file(or whatever you bootstrap with).
// change the following paths if necessary
require_once(dirname(__FILE__).'/../vendor/autoload.php');
After that replace the require_once line with:
use ZendService\LiveDocx\AbstractLiveDocx;
Hope that works :)