nette/php-generator

Autoload issue after installation and use

plasid opened this issue · 4 comments

$ composer require nette/php-generator --dev
THEN LATER IN MY OWN CODE
use Nette\PhpGenerator\ClassType;
.
$class = new ClassType('Demo');
.
.
THEN
Error: Nette\PhpGenerator\ClassType not found...
BUT
When you: composer require without the --dev flag then all works fine.
Is there a way to install it as a dev dependency and get it to autoload/resolve correctly?

mabar commented

It should work identically with and without --dev flag. Only difference is dev dependencies are not installed if you run composer install --no-dev instead of composer install

If it does not work with composer install - do you have any Composer plugins installed, that could modify autoloading or installation directory?

mabar commented

It just happened to me too. Seems like it is a Composer bug during plugins installation phase. Class which plugin uses is not available because it is from dependency that is being updated.

Full reinstall does not trigger the issue, only update from 3.x version to 4.x

image

Had the same issue, try deleting the vendor folder and the composer.lock file and run composer update

dg commented

Will you try reporting it to composer?