2017-08-01 12 views
5

पर मैंने अपने पीसी से सिम्फनी 2.8 डाउनलोड और स्थापित किया है। मैंने अपनी परियोजना की प्रतिलिपि बनाई और इसे हमारी कंपनियों के पीसी में पेस्ट किया। मैंने अभी तक डेटाबेस से बनाया और कनेक्ट नहीं किया है। मैंने php app/console server:runc:\xampp\htdocs\ninjaz\ पर करने की कोशिश की लेकिन उसके बाद मुझे यह त्रुटि संदेश मिल गया।सिम्फनी 2.8 पार्स त्रुटि: वाक्यविन्यास त्रुटि, अप्रत्याशित ':', उम्मीद है ';' या '{' में c: xampp htdocs myproject path to AnnotationRegistry.php लाइन 50

Parse error: syntax error, unexpected ':', expecting ';' or '{' in C:\xampp\htdo cs\Ninjaz\vendor\doctrine\annotations\lib\Doctrine\Common\Annotations\Annotation Registry.php on line 50

संपादित करें: मेरा अपना पीसी पीएचपी 7.1 के साथ XAMPP है। हमारी कंपनी के पीसी XAMPP पीएचपी 5.5.19

यह AnnotationRegistry.php की सामग्री है:

<?php 

namespace Doctrine\Common\Annotations; 

final class AnnotationRegistry 
{ 
/** 
* A map of namespaces to use for autoloading purposes based on a PSR-0 convention. 
* 
* Contains the namespace as key and an array of directories as value. If the value is NULL 
* the include path is used for checking for the corresponding file. 
* 
* This autoloading mechanism does not utilize the PHP autoloading but implements autoloading on its own. 
* 
* @var string[][]|string[]|null[] 
*/ 
static private $autoloadNamespaces = []; 

/** 
* A map of autoloader callables. 
* 
* @var callable[] 
*/ 
static private $loaders = []; 

/** 
* An array of classes which cannot be found 
* 
* @var null[] indexed by class name 
*/ 
static private $failedToAutoload = []; 

public static function reset() : void 
{ 
    self::$autoloadNamespaces = []; 
    self::$loaders   = []; 
    self::$failedToAutoload = []; 
} 

/** 
* Registers file. 
* 
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0 
*    autoloading should be deferred to the globally registered autoloader by then. For now, 
*    use @example AnnotationRegistry::registerLoader('class_exists') 
*/ 
public static function registerFile(string $file) : void 
{ 
    require_once $file; 
} 

/** 
* Adds a namespace with one or many directories to look for files or null for the include path. 
* 
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. 
* 
* @param string   $namespace 
* @param string|array|null $dirs 
* 
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0 
*    autoloading should be deferred to the globally registered autoloader by then. For now, 
*    use @example AnnotationRegistry::registerLoader('class_exists') 
*/ 
public static function registerAutoloadNamespace(string $namespace, $dirs = null) : void 
{ 
    self::$autoloadNamespaces[$namespace] = $dirs; 
} 

/** 
* Registers multiple namespaces. 
* 
* Loading of this namespaces will be done with a PSR-0 namespace loading algorithm. 
* 
* @param string[][]|string[]|null[] $namespaces indexed by namespace name 
* 
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0 
*    autoloading should be deferred to the globally registered autoloader by then. For now, 
*    use @example AnnotationRegistry::registerLoader('class_exists') 
*/ 
public static function registerAutoloadNamespaces(array $namespaces) : void 
{ 
    self::$autoloadNamespaces = \array_merge(self::$autoloadNamespaces, $namespaces); 
} 

/** 
* Registers an autoloading callable for annotations, much like spl_autoload_register(). 
* 
* NOTE: These class loaders HAVE to be silent when a class was not found! 
* IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class. 
* 
* @deprecated this method is deprecated and will be removed in doctrine/annotations 2.0 
*    autoloading should be deferred to the globally registered autoloader by then. For now, 
*    use @example AnnotationRegistry::registerLoader('class_exists') 
*/ 
public static function registerLoader(callable $callable) : void 
{ 
    // Reset our static cache now that we have a new loader to work with 
    self::$failedToAutoload = []; 
    self::$loaders[]   = $callable; 
} 

/** 
* Autoloads an annotation class silently. 
*/ 
public static function loadAnnotationClass(string $class) : bool 
{ 
    if (\class_exists($class, false)) { 
     return true; 
    } 

    if (\array_key_exists($class, self::$failedToAutoload)) { 
     return false; 
    } 

    foreach (self::$autoloadNamespaces AS $namespace => $dirs) { 
     if (\strpos($class, $namespace) === 0) { 
      $file = \str_replace('\\', \DIRECTORY_SEPARATOR, $class) . '.php'; 

      if ($dirs === null) { 
       if ($path = stream_resolve_include_path($file)) { 
        require $path; 
        return true; 
       } 
      } else { 
       foreach((array) $dirs AS $dir) { 
        if (is_file($dir . \DIRECTORY_SEPARATOR . $file)) { 
         require $dir . \DIRECTORY_SEPARATOR . $file; 
         return true; 
        } 
       } 
      } 
     } 
    } 

    foreach (self::$loaders AS $loader) { 
     if ($loader($class) === true) { 
      return true; 
     } 
    } 

    self::$failedToAutoload[$class] = null; 

    return false; 
    } 
} 

मैं सर्वर उन : void और : bool निकाल कर चल पाने में कामयाब रहे है, लेकिन जब मैं अपने प्रोजेक्ट ब्राउज़ करें, यह एक और त्रुटि देता है और यह पहले के साथ समान होता है लेकिन जब मैं इसे फिर से हटाने का प्रयास करता हूं, तो यह अन्य पुस्तकालयों पर एक और त्रुटि बनाता है। त्रुटि परिदृश्य के बाद यह एक अंतहीन त्रुटि की तरह है। मुझे नहीं पता कि अब क्या करना है। मैं सिम्फनी के लिए केवल नया हूँ। सहायता की आवश्यकता है।

उत्तर

5

यह PHP के गलत संस्करण के कारण होता है। मेरी भी यही समस्या थी। आपको PHP 7+ की आवश्यकता है। 7 से कम संस्करण में PHP "रिटर्न प्रकार घोषणा" का समर्थन नहीं करता है।

{ 
    "config": { 
     "platform": {"php": "5.6"} 
    } 
} 
+0

हाँ:

आप भी अपनी composer.json के लिए निम्न कोड जोड़ने की कोशिश कर सकते हैं। मुझे लगता है कि यही कारण है। मैंने अपनी परियोजना को अपने पीसी से कॉपी किया है जिसमें PHP 7 है जबकि हमारी कंपनी में, हमारे पास केवल PHP 5.6 है। – WashichawbachaW

संबंधित मुद्दे