Class name of the entity to create or update (e.g. DeliciousPuppy):
test
created: src/Entity/Test.php
created: src/Repository/TestRepository.php
Entity generated! Now let's add some fields!
You can always add more fields later manually or by re-running this command.
New property name (press to stop adding fields):
name
In MakeEntity.php line 332:
Undefined class constant 'JSON_ARRAY'
make:entity [-a|--api-resource] [--regenerate] [--overwrite] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] []
I have tried after downgrade and upgrade doctrine version but did not get solution.
Related
I updated my symfony project to version 5.3.
changed file doctrine_migrations.yaml
from:
doctrine_migrations:
dir_name: '%kernel.project_dir%/src/Migrations'
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
namespace: DoctrineMigrations
to:
doctrine_migrations:
migrations_paths:
DoctrineMigrations: '%kernel.project_dir%/src/Migrations'
and now when I run:
php bin/console doctrine:migrations:migrate
the first version that already exceuted' try to run' and get error:
An exception occurred while executing a query: SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'regions' already exists
You could try to remove previous migrations and generate a new one with
php bin/console make:migration
If your database is up to date, the new migration should be empty.
You could also empty the databse table "Migrations" to have a fresh start.
(Commit and backup files in case you want to revert)
This question already has an answer here:
Why does PHP 7.4 on Windows aborts all command line actions that require user input?
(1 answer)
Closed 1 year ago.
I just installed composer, php, apache etc. on my new SSD. After that I wanted to start coding. I opened my project from another drive in IDE. Then I wanted to load my fixtures into my new database, but I cannot. I cannot even make migrations etc. The php bin/console is broken (It automatically aborts any terminal input etc). I tried to run commands from other terminals, but it doesn't work. You can see commands below w/ or without -vvv. Thanks for any reply how to fix it.
First:
D:\project>php bin/console doctrine:fixtures:load
Careful, database "project1" will be purged. Do you want to continue?
(yes/no) [no]:
>
Aborted.
doctrine:fixtures:load [--append] [--group GROUP] [--em EM] [--shard SHARD] [--purge-with-truncate] [-h|--help] [-q|--quiet] [
-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--]
One more:
D:\project>php bin/console make:controller
Choose a name for your controller class (e.g. VictoriousGnomeController):
>
Aborted.
make:controller [--no-template] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-in
teraction] [-e|--env ENV] [--no-debug] [--] []
With verbose
D:\project>php bin/console -vvv make:controller
2019-12-10T12:48:26+00:00 [debug] Notified event "console.command" to
listener "Symfony\Component\HttpKernel\EventListener\Deb
ugHandlersListener::configure".
Choose a name for your controller class (e.g. AgreeableJellybeanController):
2019-12-10T12:48:26+00:00 [error] Error thrown while running command "-vvv make:controller". Message: "Aborted."
2019-12-10T12:48:26+00:00 [debug] Notified event "console.error" to listener "Symfony\Bundle\MakerBundle\Event\ConsoleErrorSub
scriber::onConsoleError".
2019-12-10T12:48:26+00:00 [debug] Notified event "console.error" to listener "Symfony\Component\Console\EventListener\ErrorLis
tener::onConsoleError".
2019-12-10T12:48:26+00:00 [debug] Command "-vvv make:controller" exited with code "1"
2019-12-10T12:48:26+00:00 [debug] Notified event "console.terminate" to listener
"Symfony\Bundle\MakerBundle\Event\ConsoleErro
rSubscriber::onConsoleTerminate".
2019-12-10T12:48:26+00:00 [debug] Notified event "console.terminate" to listener
"Symfony\Component\Console\EventListener\Erro
rListener::onConsoleTerminate".
In QuestionHelper.php line 137:
[Symfony\Component\Console\Exception\RuntimeException]
Aborted.
Exception trace:
at D:\apache\www\itnetwork\vendor\symfony\console\Helper\QuestionHelper.php:137
Symfony\Component\Console\Helper\QuestionHelper->doAsk() at D:\apache\www\itnetwork\vendor\symfony\console\Helper\QuestionHel
per.php:85
Symfony\Component\Console\Helper\QuestionHelper->Symfony\Component\Console\Helper{closure}()
at D:\apache\www\itnetwork\vend
or\symfony\console\Helper\QuestionHelper.php:437
Symfony\Component\Console\Helper\QuestionHelper->validateAttempts() at
D:\apache\www\itnetwork\vendor\symfony\console\Helper\
QuestionHelper.php:88
Symfony\Component\Console\Helper\QuestionHelper->ask() at D:\apache\www\itnetwork\vendor\symfony\console\Style\SymfonyStyle.p
hp:360
Symfony\Component\Console\Style\SymfonyStyle->askQuestion() at D:\apache\www\itnetwork\vendor\symfony\console\Style\SymfonySt
yle.php:267
Symfony\Component\Console\Style\SymfonyStyle->ask() at D:\apache\www\itnetwork\vendor\symfony\maker-bundle\src\Command\MakerC
ommand.php:95
Symfony\Bundle\MakerBundle\Command\MakerCommand->interact() at D:\apache\www\itnetwork\vendor\symfony\console\Command\Command
.php:240
Symfony\Component\Console\Command\Command->run() at D:\apache\www\itnetwork\vendor\symfony\console\Application.php:1029
Symfony\Component\Console\Application->doRunCommand() at D:\apache\www\itnetwork\vendor\symfony\framework-bundle\Console\Appl
ication.php:86
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at
D:\apache\www\itnetwork\vendor\symfony\console\Applicat
ion.php:272
Symfony\Component\Console\Application->doRun() at D:\apache\www\itnetwork\vendor\symfony\framework-bundle\Console\Application
.php:74
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at D:\apache\www\itnetwork\vendor\symfony\console\Application.php
:148
Symfony\Component\Console\Application->run() at D:\apache\www\itnetwork\bin\console:39
make:controller [--no-template] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-in
teraction] [-e|--env ENV] [--no-debug] [--] []
seems like this issue comes from a bug whitin the php 7.4 release on windows only
https://bugs.php.net/bug.php?id=78883
https://github.com/php/php-src/pull/4961
Other links:
https://github.com/symfony/symfony/issues/34702
https://github.com/symfony/symfony/issues/34754
https://github.com/phpMussel/phpMussel/issues/211
https://github.com/php/php-src/pull/4952
somethings is weird with my cache:clear : in dev environment there's no error but if I did with cache:clear --env=prod , I've got a "Circular reference detected for service".
What's wrong ?
Copy of the stacktrace :
Exception trace:
() at /var/www/nf-platform/symfony/app/bootstrap.php.cache:2235
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/ Symfony/Bridge/Doctrine/ManagerRegistry.php:35
Symfony\Bridge\Doctrine\ManagerRegistry->getService() at /var/www/nf-platform/symfony/vendor/doctrine/common/lib/D octrine/Common/Persistence/AbstractManagerRegistry.php:183
Doctrine\Common\Persistence\AbstractManagerRegistry->getManager() at /var/www/nf-platform/symfony/vendor/lexik/tra nslation-bundle/Lexik/Bundle/TranslationBundle/Storage/AbstractDoctrineStorage.php:48
Lexik\Bundle\TranslationBundle\Storage\AbstractDoctrineStorage->getManager() at /var/www/nf-platform/symfony/vendo r/lexik/translation-bundle/Lexik/Bundle/TranslationBundle/Storage/DoctrineORMStorage.php:19
Lexik\Bundle\TranslationBundle\Storage\DoctrineORMStorage->translationsTablesExist() at /var/www/nf-platform/symfo ny/vendor/lexik/translation-bundle/Lexik/Bundle/TranslationBundle/EventDispatcher/GetDatabaseResourcesListener.php: 41
Lexik\Bundle\TranslationBundle\EventDispatcher\GetDatabaseResourcesListener->onGetDatabaseResources() at n/a:n/a
call_user_func() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Even tDispatcher.php:184
Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at /var/www/nf-platform/symfony/vendor/symfony/sym fony/src/Symfony/Component/EventDispatcher/EventDispatcher.php:46
Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at /var/www/nf-platform/symfony/vendor/lexik/transla tion-bundle/Lexik/Bundle/TranslationBundle/Translation/Translator.php:28
Lexik\Bundle\TranslationBundle\Translation\Translator->addDatabaseResources() at /var/www/nf-platform/symfony/app/ cache/pro_/appProdProjectContaine_.php:3871
appProdProjectContaine_->getLexikTranslation_TranslatorService() at /var/www/nf-platform/symfony/app/bootstrap.php .cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:7820
appProdProjectContaine_->getTwigService() at /var/www/nf-platform/symfony/app/bootstrap.php.cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:3908
appProdProjectContaine_->getMailManagerService() at /var/www/nf-platform/symfony/app/bootstrap.php.cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:2025
appProdProjectContaine_->getFei_DoctrineListener_UserService() at /var/www/nf-platform/symfony/app/bootstrap.php.c ache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:1235
appProdProjectContaine_->getDoctrine_Dbal_DefaultConnectionService() at /var/www/nf-platform/symfony/app/bootstrap .php.cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/app/cache/pro_/appProdProje ctContaine_.php:1349
appProdProjectContaine_->getDoctrine_Orm_DefaultEntityManagerService() at /var/www/nf-platform/symfony/app/bootstr ap.php.cache:2261
Symfony\Component\DependencyInjection\Container->get() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/ Symfony/Bridge/Doctrine/ManagerRegistry.php:35
Symfony\Bridge\Doctrine\ManagerRegistry->getService() at /var/www/nf-platform/symfony/vendor/doctrine/common/lib/D octrine/Common/Persistence/AbstractManagerRegistry.php:231
Doctrine\Common\Persistence\AbstractManagerRegistry->getManagers() at /var/www/nf-platform/symfony/vendor/symfony/ symfony/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php:49
Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer->warmUp() at /var/www/nf-platform/symfony/vendor/symfony/symf ony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /var/www/nf-platform/symfony/app/bootst rap.php.cache:2775
Symfony\Component\HttpKernel\Kernel->initializeContainer() at /var/www/nf-platform/symfony/app/bootstrap.php.cache :2542
Symfony\Component\HttpKernel\Kernel->boot() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/Symfony/Bun dle/FrameworkBundle/Command/CacheClearCommand.php:134
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /var/www/nf-platform/symfony/vendor/symfony/ symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /var/www/nf-platform/symfony/vendor/symfony /symfony/src/Symfony/Component/Console/Command/Command.php:241
Symfony\Component\Console\Command\Command->run() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/Symfon y/Component/Console/Application.php:861
Symfony\Component\Console\Application->doRunCommand() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/S ymfony/Component/Console/Application.php:193
Symfony\Component\Console\Application->doRun() at /var/www/nf-platform/symfony/vendor/symfony/symfony/src/Symfony/ Bundle/FrameworkBundle/Console/Application.php:84
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/nf-platform/symfony/vendor/symfony/symfony /src/Symfony/Component/Console/Application.php:117
Symfony\Component\Console\Application->run() at /var/www/nf-platform/symfony/app/console:27
cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [-- ansi] [--no-ansi] [-n|--no-interaction] [-s|--shell] [--process-isolation] [-e|--env ENV] [--no-debug] [--] <comman d>
In my experience with Symfony I find that in some cases the cache:clear command isn't enough. Sometimes I have to clear the cache completely at file system level. Use one of the following commands instead (assuming you're in a Unix like environment).
For Symfony 2.x:
rm -rf ./app/cache/*
For Symfony 3.x and 4.x:
rm -rf ./var/cache/*
If you had any .gitkeep files in there you'll need to touch them again before committing.
You should not need to run cache:clear again after doing this, as Symfony will warm up a brand new cache on your first application request. Expect your first request to take noticeably longer to process though. (10-20 seconds can be expected depending on your app.)
About the circular reference specifically I'd suggest you have two custom service classes both of which have the Symfony service container injected into them, then try to reference each other via $this->container->get('the_other_service')->whatever();.
As of Symfony 4.0 this is no longer supported, forcing you to use dependency injection instead. (Service classes should no longer have the service container injected into them, as tempting and easy as it may appear.) -- I know the struggle this can be particularly when upgrading from Symfony 2.x or 3.x, but we're told it's for the best.
I have installed php and composer on a Windows Vista 64 machine. I am having a devil of a time getting Composer to accept a directive to use a specified directory other than the default C:\Users\\AppData\Roaming\Composer.
I tried to set up a config.json file viz:
{
"config": {
"COMPOSER_HOME": "c:\inetpub\wwwroot\PHPcomposer\",
"COMPOSER_CACHE_DIR": "c:\inetpub\wwwroot\PHPcomposer\"
}
}
and this was completely ignored. even added cache-dir for fun.
I tried altering the composer.json viz:
{
"require": {
"symfony/validator": "2.1.*",
"doctrine/dbal": "2.2.*",
"monolog/monolog": "dev-master",
"jtreminio/test-extensions": "dev-master"
},
"minimum-stability": "dev",
"config": {
"COMPOSER_HOME": "c:/inetpub/wwwroot/PHPcomposer/",
"cache-dir": "c:/inetpub/wwwroot/PHPcomposer/",
"COMPOSER_CACHE_DIR": "c:/inetpub/wwwroot/PHPcomposer/"
}
}
and still I am getting an open_basedir restriction in effect message referring to
C:\Users\<user>\AppData\Roaming\Composer
I also did a iisreset, just in case iis was caching stuff.
So, any clues as to where I am going wrong. I know I can alter php.ini, but that to me is violating the security that php is offering. I would prefer to tell Composer to behave and do what I tell it to do.
Here is the command line I used and the result of it, the same error occurs regardless of any settings in config.phar or the "config" section in composer.phar. The php.ini has open_basedir = "C:\inetpub\wwwroot":
C:\inetpub\wwwroot\PHPcomposer>composer install
[ErrorException]
file_exists(): open_basedir restriction in effect.
File(C:/Users/Stuart/AppData/Roaming/Composer/.htaccess) is not
within the allowed path(s): (C:\inetpub\wwwroot)
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev]
[--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress]
[-v|vv|vvv|--verbose] [-o|--optimize-autoloader]
You need to Create a directory c:\pathTo\composer and download composer.phar into it from here
Then setup COMPOSER_HOME and COMPOSER_CACHE_DIR before running php, in a batch file:
composer.bat
#ECHO off
SET cwd=%cd%
PUSHD "c:\pathTo\php-5.4.28"
SET COMPOSER_HOME=c:\pathTo\composer
SET COMPOSER_CACHE_DIR=c:\pathTo\composer
"c:\pathTo\php-5.4.28\php.exe" -c "c:\pathTo\phpIniDir" -ddisable_functions="" -ddisable_classes="" -n "c:\pathTo\composer\composer.phar" --working-dir="%cwd%" %*
POPD
i am trying out the Doctrine 2 sandbox. downloaded the main Doctrine 2 ORM from http://github.com/doctrine/doctrine2 the dbal from http://github.com/doctrine/dbal and common from http://github.com/doctrine/common. placed the packages in approparate folders ...
D:\ResourceLibrary\Frameworks\Doctrine\lib\Doctrine\ORM
D:\ResourceLibrary\Frameworks\Doctrine\lib\vendor\doctrine-common\lib\Doctrine\Common
D:\ResourceLibrary\Frameworks\Doctrine\lib\vendor\doctrine-dbal\lib\Doctrine\DBAL
from the sandbox folder i tried to get the version to see if everything works ok ...
D:\ResourceLibrary\Frameworks\Doctrine\tools\sandbox>php doctrine.php -V
Doctrine Command Line Interface version 2.0.0BETA4-DEV
looks ok.
D:\ResourceLibrary\Frameworks\Doctrine\tools\sandbox>php doctrine.php orm:schema-tool:create ./Entities
[RuntimeException]
Too many arguments.
orm:schema-tool:create [--dump-sql] [-h|--help] [-q|--quiet] [-v|--verbose] [-V|--version] [-c|--color] [-n|--no-interaction] command
then fails ...
how can i fix this?
This is a known problem with the tutorial. Try removing the ./Entities argument as suggested in the bug report:
http://www.doctrine-project.org/jira/browse/DWEB-53?page=com.atlassian.jira.ext.fisheye%3Afisheye-issuepanel.
Do:
php doctrine.php orm:schema-tool:create --dump-sql
For a running example of the Cookbook code that can be downloaded, see here.