I am getting error when use start command in symfony - 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

Related

api-platform/admin complains about missing json files after install

I have a functioning local install of api-platform on WSL:
http://127.0.0.1:8000/api/
However, after I ran composer require api-platform/admin-pack, I get the following 500 error at /api:
An exception has been thrown during the rendering of a template ("Asset manifest file "/mnt/c/Users/user/symfony-project-path/public/build/manifest.json" does not exist.").
Last line of stack trace:
in vendor/api-platform/core/src/Bridge/Symfony/Bundle/Resources/views/SwaggerUi/index.html.twig (line 9)
Similarly at /admin, I get the following error:
An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file "/mnt/c/Users/user/symfony-project-path/public/build/entrypoints.json" does not exist.").
Last line of stack trace:
in templates/admin.html.twig (line 9)
Was the install script supposed to create the ./build dir in ./public?
Any help would be appreciated. Thanks.
Environment
OS: Ubuntu 18.04 (WSL)
Symfony: v4.4
Try running yarn watch in your project directory.

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

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

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.

Cannot Composer Install with Symfony - PhpStorm

I had a problem with my Ubuntu so I needed to install back everything.
Nearly all is done but when I start a new project with Symfony on PhpStorm, and when I do a composer install or composer update in the terminal I have an error that I don't know how to treat.
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the symfony-scripts event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DOMDocument" from the global namespace.
Did you forget a "use" statement? in /var/www/html/Eval2/vendor/symfony/symfony/src/Symfony/Component/Config/Util/XmlUtils.php:52
Stack trace:
#0 /var/www/html/Eval2/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php(284): Symfony\Component\Config\Util\XmlUtils::loadFile('/var/www/html/E...', Array)
#1 /var/www/html/Eval2/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php(41): Symfony\Component\DependencyInjection\Loader\XmlFileLoader->parseFileToDOM('/var/ww
w/html/E...')
#2 /var/www/html/Eval2/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php(57): Symfony\Component\DependencyInjection\Loader\XmlFileLoader->load('web.xm
l')
#3 /var/www/html/Eval2/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php in /var/www/html/Eval2/vendor/symfony/symfony/src/Symfony/Component/
Config/Util/XmlUtils.php on line 52
I tried installing composer following this link
but I don't recall using such practice.
So I cannot move forward with my project because I can't get past composer... if anyone knows why and could give me a step-by-step approach that would be truly appreciated.
Thank you
PHP's DOMDocument library is not installed. You need to install it. Try -
sudo apt-get install php-dom

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

Resources