install Sylius - symfony3 on Windows

2020-06-28 11:36发布

问题:

when i excecute this command

php bin/console sylius:install

i have this

    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>

Please help me !!!!

回答1:

Sylius uses inline yaml resource format (you can find it by searching for resource: |) which is incorrectly recognized as glob pattern by Symfony 3.3 routing. This is no issue on Unix systems which have no length limit on glob patterns but it breaks on Windows (as it is sometimes longer than 260 chars).


The root problem is described with more background in https://github.com/symfony/symfony/issues/22938 and can be prevented by adding a check against newlines in the glob pattern recognition in \Symfony\Component\Config\Loader\FileLoader::import() like this:

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), '/');

Also it could be fixed in Sylius by rewriting all inline yaml routing configurations to avoid characters *, ?, { and [. I have found only arrays like:

except: ['show']

which can be rewritten as:

except:
    - 'show'

and thus avoid triggering the glob pattern recognition.


I have not found any other workaround.

Removing the 260 character path limit in Windows by registry edit (http://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/) does not help at all. The 260 limit for glob patterns is probably checked in PHP itself.