Symfony 4.3 Warning: chdir(): No such file or directory (errno 2) - symfony

i try to add a new entity with the maker bundle of Symfony, but i can't get rid of this error , any help please :/ ?
it happen right after
php bin/console make:entity
Class name of the entity to create or update (e.g. GrumpyJellybean):
> Customer
Your entity already exists! So let's add some new fields!
PHP Fatal error: During class fetch: Uncaught ErrorException: Warning: chdir(): No such file or directory (errno......
Error: During class fetch: Uncaught ErrorException: Warning: chdir(): No such file or directory (errno 2) in
/Users/loic/Documents/TFE/cmi-3/vendor/symfony/debug/DebugClassLoader.php:458
Stack trace:
#0 phar:///Users/loic/Documents/TFE/cmi-3/vendor/phpstan/phpstan-shim/phpstan.phar/vendor/nikic/php-parser/l
ib/PhpParser/Lexer/Emulative.php(12): spl_autoload_call('PhpParser\\Lexer')
#1 /Users/loic/Documents/TFE/cmi-3/vendor/symfony/maker-bundle/src/Util/ClassSourceManipulator.php(63): spl_
autoload_call('PhpParser\\Lexer...')
#2 /Users/loic/Documents/TFE/cmi-3/vendor/symfony/maker-bundle/src/Maker/MakeEntity.php(743): Symfony\Bundle
\MakerBundle\Util\ClassSourceManipulator->__construct('<?php\n\nnamespac...', false)
#3 /Users/loic/Documents/TFE/cmi-3/vendor/symfony/maker-bundle/src/Maker/MakeEntity.php(167): Symfony\Bundle
\MakerBundle\Maker\MakeEntity->createClassManipulator('/Users/loic/Doc...', Object(Symfony\Bundle\MakerBundl
e\ConsoleStyle), false)

For now i got it working with
php bin/console make:entity --no-debug
it'll do the job but i still don't know what is happening.

Related

Fatal error: Uncaught Twig\Error\LoaderError

I have just deployed my application on the server. If I use APP_ENV=dev, everything works fine but if I use APP_ENV=prod, I get the following error:
Fatal error: Uncaught Twig\Error\LoaderError: The
"/home/httpd/vhosts/example.com/httpdocs/api_tapalle\vendor\symfony\framework-bundle/Resources/views"
directory does not exist
("/home/httpd/vhosts/example.com/httpdocs/api_tapalle\vendor\symfony\framework-bundle/Resources/views").
in
/home/httpd/vhosts/example.com/httpdocs/api_tapalle/vendor/twig/twig/src/Loader/FilesystemLoader.php:106
Stack trace: #0
/home/httpd/vhosts/example.com/httpdocs/api_tapalle/var/cache/prod/ContainerTP5linE/srcApp_KernelProdContainer.php(471):
Twig\Loader\FilesystemLoader->addPath('/home/httpd/vho...',
'Framework') #1
/home/httpd/vhosts/example.com/httpdocs/api_tapalle/var/cache/prod/ContainerTP5linE/srcApp_KernelProdContainer.php(729):
ContainerTP5linE\srcApp_KernelProdContainer->getTwigService() #2
/home/httpd/vhosts/example.com/httpdocs/api_tapalle/var/cache/prod/ContainerTP5linE/srcApp_KernelProdContainer.php(346):
ContainerTP5linE\srcApp_KernelProdContainer->getSensioFrameworkExtra_View_ListenerService() #3 /home/httpd/vhosts/y in /home/httpd/vhosts/example.com/httpdocs/api_tapalle/vendor/twig/twig/src/Loader/FilesystemLoader.php
on line 106
Since I have this error, I have used php bin/console cache:clear -e prod to clear the cache and then uploaded var and vendor directories again.
The weird thing is that vendor\symfony\framework-bundle/Resources/views and vendor/twig/twig/src/Loader/FilesystemLoader.php exist on the server!
Why do I get this error?
updlas the project with all the cache production, dont make a cache clear

I am getting error when use start command in symfony

I am very new to Symfony. I have installed Symfony in my system with symfony demo command it's working fine. I installed in that folder already developed project code. when use php bin/console server:start 0.0.0.0:8000 this command I am getting error:
PHP Fatal error: Uncaught RuntimeException: The autoloader expected class "AppKernel" to be defined in file "/home/Desktop/commercetools-sunrise-php-master/vendor/composer/../../app/AppKernel.php". The file was found but the class was not in it, the class name or namespace probably has a typo. in /home/Desktop/commercetools-sunrise-php-master/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php:223
Stack trace:#0 [internal function]: Symfony\Component\Debug\DebugClassLoader->loadClass('AppKernel')#1 /home/Desktop/commercetools-sunrise-php-master/bin/console(26): spl_autoload_call('AppKernel')#2 {main}
thrown in /home/Desktop/commercetools-sunrise-php-master/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php on line 223
Any one can help me. Thanks in advance.
There may be a corrupted generated PHP file. Try this :
composer run-script post-install-cmd

Symfony2 Permission Denied error while creating a bundle

First of all, I want to say I might be missing something basic, but I'm actually new in Symfony.
While I'm creating a bundle from terminal(I'm using mac), it gives me that error;
[UnexpectedValueException]
The stream or file "/Applications/MAMP/htdocs/Symfony/app/logs/dev.log" cou
ld not be opened: failed to open stream: Permission denied
Here is the code for creating a bundle
php app/console generate:bundle --namespace=Ens/JobeetBundle --format=yml
I believe that your permissions were not set correctly. Here is how to set it up - http://symfony.com/doc/current/book/installation.html#configuration-and-setup

Symfony2 FOSUserBundle and groups error

i am getting an error, when applying
php app/console doctrine:schema:update --force
i get a stack of errors, starting with
PHP Fatal error: Declaration of Tracker\MembersBundle\Entity\User::addGroup() must be
compatible with that of FOS\UserBundle\Model\GroupableInterface::addGroup() in C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\src\Tracker\MembersBundle\Entity\User.php on line 14
PHP Stack trace:
PHP 1. {main}() C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\app\console:0
PHP 2. Symfony\Component\Console\Application->run() C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\app\console:22
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\vendor\symfony\src\Symfony\Component\Console\Application.php:118
PHP 4. Symfony\Component\Console\Application->doRun() C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\vendor\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:75
i figured out User::addGroup() and the groups implementation of FOSUserBundle ...but i do not know how to ultimately solve it...here are my two entities
User
Group
Update:
if i simply remove addGroup() from the User Entity, and go to the path
http://mysite.com/app_dev.php/group/new
i get a fatal error
Fatal error: Declaration of FOS\UserBundle\Form\Type\GroupFormType::getDefaultOptions() must be compatible with that of Symfony\Component\Form\FormTypeInterface::getDefaultOptions() in C:\Program Files (x86)\Zend\Apache2\htdocs\mysite\vendor\bundles\FOS\UserBundle\Form\Type\GroupFormType.php on line 18
You have to add FQCN of GroupableInterface in your User class e.g
use FOS\UserBundle\Model\GroupableInterface;
Edit:
You have to update symfony. As they have changed function signature of getDefaultOptions. Check here.
you should remove from:
vendor\yourBundle\Entity\User;
getter setter group function coz it was already declared on
use FOS\UserBundle\Model\User.php;
it can be duplicate function !
now generate your schema i hope it helps you :D

symfony2 load fixtures gives error, please advise on how to fix?

i am on part Updating the blog entity where i need to load the fixtures with command:
$ php app/console doctrine:fixtures:load
but i get an error:
php app/console doctrine:fixtures:load
> purging database
> loading Blogger\BlogBundle\DataFixtures\ORM\BlogFixtures
> loading Blogger\BlogBundle\DataFixtures\ORM\CommentFixtures
[ErrorException]
Warning: file_put_contents(/home/helloises/symfony2/Symfony/app/cache/dev/doctrine/orm/Proxies/Blogge rBlogBundleEntityBlogProxy.php): failed to open stream: Permission denied in
/home/helloises/symfony2/Symfony/vendor/doctrine/lib/Doctrine/ORM/Proxy/ProxyFactory.php
line 155
please help?
thanks
This is a permission error:
You don't have the write permission in the app/cache/dev/doctrine/orm/Proxies directory of your project so doctrine fails to create its proxy classes.
Maybe you gave the write permission to your HTTP server user (so the web works) but not to the user you used to execute the command.
See the Setting up Permissions paragraph in http://symfony.com/doc/current/book/installation.html#configuration-and-setup

Resources