0

I am attempting to achieve the Inchoo Shipping Magento 2 example. When I run 'setup:di:compile', I receive this error: 'Parse error: syntax error, unexpected 'class' (T_CLASS)'. I am not sure what is wrong with my formatting that is causing this. Can post the whole code, but it seems irrelevant as the error is occurring at the introduction of the class

Code Snippet:

<?php

namespace Inchoo_Shipping\Shipping\Model\Carrier;

use Magento\Quote\Model\Quote\Address\RateResult\Error;
use Magento\Quote\Model\Quote\Address\RateRequest;
use Magento\Shipping\Model\Carrier\AbstractCarrierOnline;
use Magento\Shipping\Model\Carrier\CarrierInterface;
use Magento\Shipping\Model\Rate\Result;

class Example extends \Magento\Shipping\Model\Carrier\AbstractCarrier implements
\Magento\Shipping\Model\Carrier\CarrierInterface
{
/**
 * @var string
 */
protected $_code = 'example';
Jb1128
  • 87
  • 2
  • 10

1 Answers1

0

What version of php you are using?

Magento 2 requires php 5.6+.

If you using php below 5.5, this error may be thrown because this:

Since PHP 5.5, the class keyword is also used for class name resolution. You can get a string containing the fully qualified name of the ClassName class by using ClassName::class. This is particularly useful with namespaced classes.

Ovsyanka
  • 399
  • 3
  • 11
  • I am using 5.6. So, I've managed to fix the error by changing the name of the initial namespace file. I got rid of the underscore and it seems to be running now – Jb1128 Jan 30 '17 at 02:51