在 Windows 上安装 Sylius - symfony3

install Sylius - symfony3 on Windows

当我执行这个命令时

php bin/console sylius:install

我有这个

    C:\wamp\www\p>php bin/console sylius:install
Installing Sylius...

           ,
         ,;:,
       `;;;.:`
      `::;`  :`
       :::`   `          .'++:           ''.   '.
       `:::             :+',;+'          :+;  `+.
        ::::            +'   :'          `+;
        `:::,           '+`     ++    :+.`+; `++. ;+'    ''  ,++++.
         ,:::`          `++'.   .+:  `+' `+;  .+,  ;+    +'  +;  ''
          ::::`           ,+++.  '+` :+. `+;  `+,  ;+    +'  '+.
   ,.     .::::             .++` `+: +'  `+;  `+,  ;+    +'  `;++;
`;;.:::`   :::::             :+.  '+,+.  `+;  `+,  ;+   `+'     .++
 .;;;;;;::`.::::,       +'` `++   `++'   `+;  `+:  :+. `++'  '.  ;+
  ,;;;;;;;;;:::::       .+++++`    ;+,    ++;  ++, `'+++,'+' :++++,
   ,;;;;;;;;;:::`                  ;'
    :;;;;;;;;;:,                :.:+,
     ;;;;;;;;;:                 ;++

Step 1 of 4. Checking system requirements.
------------------------------------------

+----------------------------+-------------------------------------------------+
| Issue                      | Recommendation                                  |
+----------------------------+-------------------------------------------------+
| Version de PHP recommandée |                                                 |
| Accélérateur               | Activez le OpCache Zend (fortement recommandé). |
+----------------------------+-------------------------------------------------+
Success! Your system can run Sylius properly.

Step 2 of 4. Setting up the database.
-------------------------------------

Creating Sylius database for environment dev.
It appears that your database already exists.
Warning! This action will erase your database.
Would you like to reset it? (y/N) y
 0/5 [Γûæ                           ]   0%
 1/5 [ΓûæΓûæΓûæΓûæΓûæΓûæ                      ]  20%
 2/5 [ΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæ                ]  40%
 3/5 [ΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæΓûæ           ]  60%

  [Symfony\Component\Config\Exception\FileLoaderLoadException]
  Warning: glob(): Pattern exceeds the maximum allowed length of 260 characte
  rs in C:\wamp\www\p\src\Sylius\Bundle\AdminBundle/Resources/config/routing/
  admin_user.yml (which is being imported from "C:\wamp\www\p\src\Sylius\Bund
  le\AdminBundle/Resources/config/routing.yml").



  [Symfony\Component\Debug\Exception\ContextErrorException]
  Warning: glob(): Pattern exceeds the maximum allowed length of 260 characte
  rs


cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

请帮帮我!!!!

Sylius 使用内联 yaml 资源格式(您可以通过搜索 resource: | 找到它),它被 Symfony 3.3 路由错误地识别为 glob 模式。这在 Unix 系统上没有问题,它对 glob 模式没有长度限制,但它会在 Windows 上中断(因为它有时超过 260 个字符)。


根本问题在 https://github.com/symfony/symfony/issues/22938 中有更多背景描述,可以通过在 \Symfony\Component\Config\Loader\FileLoader::import() 的 glob 模式识别中添加对换行符的检查来防止,如下所示:

84:      public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null)
85:      {
86: -        if (is_string($resource) && strlen($resource) !== $i = strcspn($resource, '*?{[')) {
86: +        if (is_string($resource) && false === strpos($resource, "\n") && strlen($resource) !== $i = strcspn($resource, '*?{[')) {
87:              $ret = array();
88:              $isSubpath = 0 !== $i && false !== strpos(substr($resource, 0, $i), '/');

也可以通过重写所有内联 yaml 路由配置以避免字符 *?{[ 在 Sylius 中修复它。我只找到像这样的数组:

except: ['show']

可以改写为:

except:
    - 'show'

从而避免触发 glob 模式识别。


我还没有找到任何其他解决方法。

通过注册表编辑 (http://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/) 删除 Windows 中的 260 个字符路径限制根本没有帮助。可能在 PHP 本身检查了 glob 模式的 260 限制。