Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is no way to use PHP 7.2 or 7.3 #35934

Closed
andchir opened this issue Mar 3, 2020 · 22 comments
Closed

There is no way to use PHP 7.2 or 7.3 #35934

andchir opened this issue Mar 3, 2020 · 22 comments

Comments

@andchir
Copy link

andchir commented Mar 3, 2020

Symfony version(s) affected: ALL

Description
Symfony depends on "ocramius/proxy-manager", proxy-manager 2.2 depends on "zendframework/zend-code", but "zendframework/zend-code" abandoned https://packagist.org/packages/zendframework/zend-code
Newer versions of "proxy-manager" use "laminas/laminas-code", but they require PHP 7.4 only.

How to reproduce
Try using PHP 7.2 or 7.3. I got error:

Attempted to load class "ClassGenerator" from namespace "Zend\Code\Generator". Did you forget a "use" statement for "Laminas\Code\Generator\ClassGenerator"? - /vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ClassGenerator.php (15)

Because the package "zendframework/zend-code" abandoned.

Possible Solution
Refuse to use "proxy-manager" because he is always in a hurry to use only the latest versions of PHP. Look for another replacement or develop your own solution. Or ask the author not to rush to use the latest versions of PHP.

@andchir
Copy link
Author

andchir commented Mar 3, 2020

Possible Solution: add depending "laminas/laminas-code".

@stof
Copy link
Member

stof commented Mar 3, 2020

I'm not getting any error on PHP 7.3 (I'm getting a composer warning about zendframework/zend-code being abandoned though). Have you done something special that you haven't explained in your issue ?

@andchir
Copy link
Author

andchir commented Mar 3, 2020

Perhaps this is my local problem. It does not install "zendframework/zend-code" and I do not see a warning. But it is installed if I install new Symfony project and then I see a warning about "zend-code". I tried to delete "vendor" folder and run composer install --no-dev, but it does not install "zendframework/zend-code" for some reason.

While I do not know how you can reproduce it.

@xabbuh
Copy link
Member

xabbuh commented Mar 3, 2020

What is the exact error that you get locally?

@andchir
Copy link
Author

andchir commented Mar 4, 2020

@xabbuh

[2020-03-04 07:49:37] php.CRITICAL: Class 'Zend\Code\Generator\ClassGenerator' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'Zend\\Code\\Generator\\ClassGenerator' not found at /var/www/symfony_project/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ClassGenerator.php:15)"} []

I think a dependency is written somewhere as a dev, so it is not installed with the flag --no-dev. Until I not found, maybe doctrine mongodb.

@andchir
Copy link
Author

andchir commented Mar 4, 2020

My composer.json:

{
    "name": "andchir/project",
    "type": "project",
    "license": "proprietary",
    "require": {
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-json": "*",
        "ext-zip": "*",
        "alcaeus/mongo-php-adapter": "^1.1",
        "andchir/omnipay-bundle": "^1.0",
        "andchir/shopkeeper4-comments": "^1.0",
        "behat/transliterator": "^1.3",
        "composer/composer": "^1.8",
        "doctrine/cache": "^1.8",
        "doctrine/doctrine-cache-bundle": "^1.3",
        "doctrine/doctrine-fixtures-bundle": "^3.2",
        "doctrine/mongodb-odm-bundle": "^4.0",
        "gregwar/captcha-bundle": "^2.0",
        "liip/imagine-bundle": "^2.1",
        "mongodb/mongodb": "^1.4",
        "phpoffice/phpspreadsheet": "^1.10",
        "ralouphie/mimey": "^2.0",
        "sensio/framework-extra-bundle": "^5.2",
        "symfony/asset": "*",
        "symfony/console": "*",
        "symfony/dotenv": "*",
        "symfony/expression-language": "*",
        "symfony/flex": "^1.1",
        "symfony/form": "*",
        "symfony/framework-bundle": "*",
        "symfony/monolog-bundle": "^3.1",
        "symfony/orm-pack": "*",
        "symfony/process": "*",
        "symfony/requirements-checker": "^1.1",
        "symfony/security-bundle": "*",
        "symfony/serializer": "*",
        "symfony/serializer-pack": "*",
        "symfony/swiftmailer-bundle": "^3.1",
        "symfony/translation": "*",
        "symfony/twig-bundle": "*",
        "symfony/validator": "*",
        "symfony/web-link": "*",
        "symfony/yaml": "*"
    },
    "require-dev": {
        "symfony/debug-pack": "*",
        "symfony/maker-bundle": "^1.7",
        "symfony/profiler-pack": "*",
        "symfony/test-pack": "*",
        "symfony/web-server-bundle": "*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "platform": {
            "ext-mongo": "1.6.16",
            "php": "7.3.0"
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/App/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd",
            "requirements-checker": "script"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": true,
            "require": "4.4.*"
        }
    }
}

@xabbuh
Copy link
Member

xabbuh commented Mar 4, 2020

What is the output of composer show?

@andchir
Copy link
Author

andchir commented Mar 4, 2020

@xabbuh

alcaeus/mongo-php-adapter            1.1.11  Adapter to provide ext-mongo interface on top of mongo-php-l...
andchir/omnipay-bundle               1.0.15  Omnipay bundle for Symfony 4.x
andchir/omnipay3-yandexkassa         v1.0.5  Payment gateway module for Omnipay: Yandex kassa(checkout) f...
andchir/shopkeeper4-comments         v1.0.10 Reviews and ratings for Symfony4
andrewnovikof/omnipay-sberbank       3.2.1   Omnipay driver for Sberbank
behat/transliterator                 v1.3.0  String transliterator
clue/stream-filter                   v1.4.1  A simple and modern approach to stream filtering in PHP
composer/ca-bundle                   1.2.6   Lets you find a path to the system CA bundle, and includes a...
composer/composer                    1.9.3   Composer helps you declare, manage and install dependencies ...
composer/semver                      1.5.1   Semver library that offers utilities, version constraint par...
composer/spdx-licenses               1.5.3   SPDX licenses list and validation library.
composer/xdebug-handler              1.4.1   Restarts a process without Xdebug.
doctrine/annotations                 v1.8.0  Docblock Annotations Parser
doctrine/cache                       1.10.0  PHP Doctrine Cache library is a popular cache implementation...
doctrine/collections                 1.6.4   PHP Doctrine Collections library that adds additional functi...
doctrine/common                      2.12.0  PHP Doctrine Common project is a library that provides addit...
doctrine/data-fixtures               1.4.2   Data Fixtures for all Doctrine Object Managers
doctrine/dbal                        v2.10.1 Powerful PHP database abstraction layer (DBAL) with many fea...
doctrine/doctrine-bundle             2.0.7   Symfony DoctrineBundle
doctrine/doctrine-cache-bundle       1.4.0   Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle    3.3.0   Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle  2.1.2   Symfony DoctrineMigrationsBundle
doctrine/event-manager               1.1.0   The Doctrine Event Manager is a simple PHP event system that...
doctrine/inflector                   1.3.1   Common String Manipulations with regard to casing and singul...
doctrine/instantiator                1.3.0   A small, lightweight utility to instantiate objects in PHP w...
doctrine/lexer                       1.2.0   PHP Doctrine Lexer parser library that can be used in Top-Do...
doctrine/migrations                  2.2.1   PHP Doctrine Migrations project offer additional functionali...
doctrine/mongodb-odm                 2.0.5   PHP Doctrine MongoDB Object Document Mapper (ODM) provides t...
doctrine/mongodb-odm-bundle          4.1.0   Symfony2 Doctrine MongoDB Bundle
doctrine/orm                         v2.7.1  Object-Relational-Mapper for PHP
doctrine/persistence                 1.3.6   The Doctrine Persistence project is a set of shared interfac...
doctrine/reflection                  v1.1.0  The Doctrine Reflection project is a simple library used by ...
egulias/email-validator              2.1.17  A library for validating emails against several RFCs
gregwar/captcha                      v1.1.8  Captcha generator
gregwar/captcha-bundle               v2.1.2  Captcha bundle
guzzlehttp/guzzle                    6.5.2   Guzzle is a PHP HTTP client library
guzzlehttp/promises                  v1.3.1  Guzzle promises library
guzzlehttp/psr7                      1.6.1   PSR-7 message implementation that also provides common utili...
hiqdev/omnipay-robokassa             3.2.0   RoboKassa driver for Omnipay PHP payment library
imagine/imagine                      1.2.3   Image processing for PHP 5.3
jdorn/sql-formatter                  v1.2.17 a PHP SQL highlighting library
justinrainbow/json-schema            5.2.9   A library to validate a json schema.
laminas/laminas-code                 3.4.1   Extensions to the PHP Reflection API, static code scanning, ...
laminas/laminas-eventmanager         3.2.1   Trigger and listen to events within a PHP application
laminas/laminas-zendframework-bridge 1.0.1   Alias legacy ZF class names to Laminas Project equivalents.
league/omnipay                       v3.0.2  Omnipay payment processing library
liip/imagine-bundle                  2.3.0   This bundle provides an image manipulation abstraction toolk...
markbaker/complex                    1.4.7   PHP Class for working with complex numbers
markbaker/matrix                     1.2.0   PHP Class for working with matrices
moneyphp/money                       v3.3.0  PHP implementation of Fowler's Money pattern
mongodb/mongodb                      1.6.0   MongoDB driver library
monolog/monolog                      1.25.3  Sends your logs to files, sockets, inboxes, databases and va...
ocramius/package-versions            1.5.1   Composer plugin that provides efficient querying for install...
ocramius/proxy-manager               2.2.3   A library providing utilities to generate, instantiate and g...
omnipay/common                       v3.0.2  Common components for Omnipay payment processing library
omnipay/paypal                       v3.0.2  PayPal gateway for Omnipay payment processing library
php-http/discovery                   1.7.4   Finds installed HTTPlug implementations and PSR-7 message fa...
php-http/guzzle6-adapter             v2.0.1  Guzzle 6 HTTP Adapter
php-http/httplug                     2.1.0   HTTPlug, the HTTP client abstraction for PHP
php-http/message                     1.8.0   HTTP Message related tools
php-http/message-factory             v1.0.2  Factory interfaces for PSR-7 HTTP Message
php-http/promise                     v1.0.0  Promise used for asynchronous HTTP requests
phpdocumentor/reflection-common      2.0.0   Common reflection classes used by phpdocumentor to reflect t...
phpdocumentor/reflection-docblock    4.3.4   With this component, a library can provide support for annot...
phpdocumentor/type-resolver          1.1.0   A PSR-5 based resolver of Class names, Types and Structural ...
phpoffice/phpspreadsheet             1.11.0  PHPSpreadsheet - Read, Create and Write Spreadsheet document...
psr/cache                            1.0.1   Common interface for caching libraries
psr/container                        1.0.0   Common Container Interface (PHP FIG PSR-11)
psr/http-client                      1.0.0   Common interface for HTTP clients
psr/http-message                     1.0.1   Common interface for HTTP messages
psr/link                             1.0.0   Common interfaces for HTTP links
psr/log                              1.1.2   Common interface for logging libraries
psr/simple-cache                     1.0.1   Common interfaces for simple caching
ralouphie/getallheaders              3.0.3   A polyfill for getallheaders.
ralouphie/mimey                      2.1.0   PHP package for converting file extensions to MIME types and...
seld/jsonlint                        1.7.2   JSON Linter
seld/phar-utils                      1.1.0   PHAR file format utilities, for when PHP phars you up
sensio/framework-extra-bundle        v5.5.3  This bundle provides a way to configure your controllers wit...
swiftmailer/swiftmailer              v6.2.3  Swiftmailer, free feature-rich PHP mailer
symfony/asset                        v4.4.5  Symfony Asset Component
symfony/cache                        v4.4.5  Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts              v2.0.1  Generic abstractions related to caching
symfony/config                       v4.4.5  Symfony Config Component
symfony/console                      v4.4.5  Symfony Console Component
symfony/debug                        v4.4.5  Symfony Debug Component
symfony/dependency-injection         v4.4.5  Symfony DependencyInjection Component
symfony/doctrine-bridge              v4.4.5  Symfony Doctrine Bridge
symfony/dotenv                       v4.4.5  Registers environment variables from a .env file
symfony/error-handler                v4.4.5  Symfony ErrorHandler Component
symfony/event-dispatcher             v4.4.5  Symfony EventDispatcher Component
symfony/event-dispatcher-contracts   v1.1.7  Generic abstractions related to dispatching event
symfony/expression-language          v4.4.5  Symfony ExpressionLanguage Component
symfony/filesystem                   v4.4.5  Symfony Filesystem Component
symfony/finder                       v4.4.5  Symfony Finder Component
symfony/flex                         v1.6.2  Composer plugin for Symfony
symfony/form                         v4.4.5  Symfony Form Component
symfony/framework-bundle             v4.4.5  Symfony FrameworkBundle
symfony/http-foundation              v4.4.5  Symfony HttpFoundation Component
symfony/http-kernel                  v4.4.5  Symfony HttpKernel Component
symfony/inflector                    v4.4.5  Symfony Inflector Component
symfony/intl                         v4.4.5  A PHP replacement layer for the C intl extension that includ...
symfony/mime                         v4.4.5  A library to manipulate MIME messages
symfony/monolog-bridge               v4.4.5  Symfony Monolog Bridge
symfony/monolog-bundle               v3.5.0  Symfony MonologBundle
symfony/options-resolver             v4.4.5  Symfony OptionsResolver Component
symfony/orm-pack                     v1.0.8  A pack for the Doctrine ORM
symfony/polyfill-intl-icu            v1.14.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn            v1.14.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 fun...
symfony/polyfill-mbstring            v1.14.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72               v1.14.0 Symfony polyfill backporting some PHP 7.2+ features to lower...
symfony/polyfill-php73               v1.14.0 Symfony polyfill backporting some PHP 7.3+ features to lower...
symfony/process                      v4.4.5  Symfony Process Component
symfony/property-access              v4.4.5  Symfony PropertyAccess Component
symfony/property-info                v4.4.5  Symfony Property Info Component
symfony/requirements-checker         v1.1.5  Check Symfony requirements and give recommendations
symfony/routing                      v4.4.5  Symfony Routing Component
symfony/security-bundle              v4.4.5  Symfony SecurityBundle
symfony/security-core                v4.4.5  Symfony Security Component - Core Library
symfony/security-csrf                v4.4.5  Symfony Security Component - CSRF Library
symfony/security-guard               v4.4.5  Symfony Security Component - Guard
symfony/security-http                v4.4.5  Symfony Security Component - HTTP Integration
symfony/serializer                   v4.4.5  Symfony Serializer Component
symfony/serializer-pack              v1.0.2  A pack for the Symfony serializer
symfony/service-contracts            v2.0.1  Generic abstractions related to writing services
symfony/stopwatch                    v4.4.5  Symfony Stopwatch Component
symfony/swiftmailer-bundle           v3.4.0  Symfony SwiftmailerBundle
symfony/templating                   v4.4.5  Symfony Templating Component
symfony/translation                  v4.4.5  Symfony Translation Component
symfony/translation-contracts        v2.0.1  Generic abstractions related to translation
symfony/twig-bridge                  v4.4.5  Symfony Twig Bridge
symfony/twig-bundle                  v4.4.5  Symfony TwigBundle
symfony/validator                    v4.4.5  Symfony Validator Component
symfony/var-dumper                   v4.4.5  Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter                 v4.4.5  A blend of var_export() + serialize() to turn any serializab...
symfony/web-link                     v4.4.5  Symfony WebLink Component
symfony/yaml                         v4.4.5  Symfony Yaml Component
twig/twig                            v3.0.3  Twig, the flexible, fast, and secure template language for PHP
webmozart/assert                     1.7.0   Assertions to validate method input/output with nice error m...

If I add requirement

"laminas/laminas-code": "^3.4",

this solves the problem for me.

@xabbuh
Copy link
Member

xabbuh commented Mar 4, 2020

I fail to see how you ended up with zendframework/zend-code not being installed as it is a requirement of ocramius/proxy-manager 2.2.3.

@Taluu
Copy link
Contributor

Taluu commented Mar 4, 2020

Try composer why-not zendframework/zend-code ?

@andchir
Copy link
Author

andchir commented Mar 5, 2020

Now I have always installed laminas/laminas-code, but it is not in my composer.json. Perhaps this was somehow related to the composer cache. I think this issue can be closed.

@goetas
Copy link
Contributor

goetas commented Mar 9, 2020

In my opinion the problem is that laminas repositories declare themselves as replacement for zend packages, but that is not true since they have different namespaces... Cc @Ocramius @weierophinney

It should be possible to install zend and laminas packages together

@Ocramius
Copy link
Contributor

Ocramius commented Mar 9, 2020

There's a bridge library that aliases package classes for this purpose: https://github.com/laminas/laminas-zendframework-bridge

@goetas
Copy link
Contributor

goetas commented Mar 9, 2020

Similar error report doctrine/DoctrineMigrationsBundle#300

@weierophinney
Copy link

@goetas They actually are replacements. Here's why.

Every single Laminas package release includes the package laminas/laminas-zendframework-bridge as a dependency. This package includes two autoloaders:

  • The first prepends, and checks to see if the requested class is a ZF class. If so, it then checks to see if a Laminas equivalent exists, and, if so, it will add a class_alias, aliasing the ZF class to the replacement. PHP treats these as equivalents then.

  • The second runs after a Laminas class has already been autoloaded. In such a scenario, it adds a class_alias to the original ZF class, so that you can reference via the ZF namespace. Again, PHP treats them as equivalents.

There's more on this on a blog post we just released today: https://getlaminas.org/blog/2020-03-09-transferring-zf-to-laminas.html

@goetas
Copy link
Contributor

goetas commented Mar 9, 2020

Quite unfortunate decision, but I guess that other options were considered... Thanks for the feedback @Ocramius

@weierophinney
Copy link

@goetas Yes — but note the first thing I said: every Laminas package adds the bridge package as a dependency. You cannot install any of them without it.

I'd love to hear why you feel it's an "unfortunate decision". Feel free to contact me directly (matthew [at] weierophinney [dot] net), so we don't pollute this issue. That said, please be aware we did extensive testing, particularly with a variety of 3rd party libraries, before going with this approach. It was not an arbitrary decision.

@mmarton
Copy link

mmarton commented Mar 10, 2020

Sounds good, doesn't work (in all circumstances). Like using authoritive classmap (composer install -a --no-dev aka production mode) because it skips the autoload functions.

https://getcomposer.org/doc/articles/autoloader-optimization.md#optimization-level-2-a-authoritative-class-maps

@Ocramius
Copy link
Contributor

@mmarton
Copy link

mmarton commented Mar 10, 2020

Further investigating, and I'm not sure it's the authoritive flag:

$ rm -rf var/cache/prod/ vendor/
# no optimisation
$ php ../composer-stable.phar install --no-dev
# you need to have at least 1 migration to run
$ php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration

# PHP Fatal error:  Class 'Zend\Code\Generator\ClassGenerator' not found in .../vendor/ocramius/proxy-manager/src/ProxyManager/Generator/ClassGenerator.php on line 15
# 11:22:56 CRITICAL  [php] Fatal Error: Class 'Zend\Code\Generator\ClassGenerator' not found ["exception" => Symfony\Component\ErrorHandler\Error\FatalError^ { …}]

$ php ../composer-stable.phar dump-autoload
$ php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration
# finished in 261.3ms
#  ++ used 16M memory
#  ++ 1 migrations executed
#  ++ 1 sql queries

@stof
Copy link
Member

stof commented Apr 2, 2020

@mmarton @andchir according to laminas/laminas-zendframework-bridge#64 this might be an issue in the composer autoload generation for Composer < 1.10. Can you confirm whether using Composer 1.10+ fixes it ? You could post the answer directly to the laminas issue.

@dennisameling
Copy link

@stof can confirm that updating to Composer 1.10+ fixes this issue, we were having the exact same issue with Mautic: mautic/mautic#8826 (comment)

Thanks a lot for the info 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants