Symfony delete a bundle manually - php

I tried to delete a bundle manually, but an error appeared...
I guess I forgot an essential edition, but I don't know what.
I deleted the file of that bundle, I delete its line in the AppKernel, and I deleted it's lines in the app/routing.yml.
Here is the error :
FileLoaderLoadException in FileLoader.php line 118:
Bundle "DbToYmlBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in #DbToYmlBundle/Resources/config/services.yml (which is being imported from "/opt/lampp/htdocs/dublin/app/config/config.yml"). Make sure the "DbToYmlBundle" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "#DbToYmlBundle/Resources/config/services.yml" is not empty.
Could someone help to find what is wrong ?

The error message states that the #DbToYmlBundle/Resources/config/services.yml is imported from /opt/lampp/htdocs/dublin/app/config/config.yml
Please check your config.yml's or provide some more information/codes, maybe the output for your prod.log /opt/lampp/htdocs/dublin/app/logs/prod.log

You can try to clear the cache with the console.
For the Dev environment:
php bin/console cache:clear
And for production environment :
php bin/console cache:clear --env=prod

Related

Can not run in DEV environment

I write you because I have a problem to run my project Symfony 4 DEV environment. Indeed, I have the impression that this one does not turn correctly because:
when I make a modification it is not visible immediately and I usually have to empty the caches to see them
the profiler and the associated "black bar" do not appear and return a 404 (I have the body tags in my base.htm.twig)
he does not see "immediately" the roads that I created
I installed the profiler via the following command composer require profiler --dev and I am in web server (directly on my NDD and my server).
I also have the variable APP_ENV in dev and it shows me well "dev" when I display it directly in a twig via {{app.environment}}
I hope that my explanations are clear enough and that you will be able to help me. thank you in advance
ps: sorry for my English, but I'm on Google Translate ;)
EDIT : I found the solution with the help of someone on Symfony slack ... I did not install the apache-pack bundle which created a .htaccess file in the public folder and manages the rewrites of url ... that's why my roads were not found.
For my defense, I did not see this bundle anywhere in the documentation
The first you have to install symfony/dotenv (dotenv)
In the .env follow this:
APP_ENV=dev
If you have not install symfony/dotenv
composer require symfony/dotenv
You can read about this here https://symfony.com/doc/current/components/dotenv.html
Also you have to follow config/packages/dev/web_profiler.yaml:
web_profiler:
toolbar: true
intercept_redirects: false
framework:
profiler: { only_exceptions: false }
It's not mandatory added APP_ENV=dev to your .env.
In Symfony 4 you can see in public/index.php this
if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
}
$env = $_SERVER['APP_ENV'] ?? 'dev';
So if you APP_ENV is empty also you environment use is dev, but it's better use APP_ENV in .env

Trouble deploying Symfony3 on a new server

I have used Symfony a lot in the past and haven't had many problems. I have been trying to deploy it on a different server (Ubuntu 16 w/ Apache) and am having a lot of issues.
I am getting 500 error now (https://bereanboard.com/app_dev.php). What I have tried is to go to *.com/config.php and *.com/app_dev.php to see issues (I had to temporarily comment out the section that forbids access from non localhost). I have also been checking the Apache error.log and Symfony's var/logs/prod.log.
Keep in mind it works fine on local MAMP and on my previous CentOS.
First, I am for the first time encountering permission problems for var/cache and var/logs. This was pretty easy to fix with commands like chmod -R 777 var/cache. But why did this issue come up only on this new server? Anyway, config.php on the new server is now telling me "All checks passed".
Second, in var/logs/prod.log I am getting all sorts of 'Can't find class, did you forget a "use" statement?' errors. Some of these are for a twig extension AppBundle/Twig/AppExtension.php.
Here are some Critical erros:
request.CRITICAL: Uncaught PHP Exception InvalidArgumentException:
"Class "AppBundle\Controller\HomeController" does not exist." at
/home/travis/var/cache/prod/classes.php line 4872
{"exception":"[object] (InvalidArgumentException(code: 0): Class
\"AppBundle\Controller\HomeController\" does not exist. at
/home/travis/var/cache/prod/classes.php:4872)"} []
and
php.CRITICAL: Class 'AppBundle\Twig\AppExtension' not found
{"exception":"[object]
(Symfony\Component\Debug\Exception\FatalThrowableError(code: 0):
Class 'AppBundle\Twig\AppExtension' not found at
/home/travis/var/cache/prod/appProdProjectContainer.php:2881)"} []
[2017-01-19 06:35:03] request.CRITICAL: Uncaught PHP Exception
Symfony\Component\Debug\Exception\ClassNotFoundException: "Attempted
to load class "AppExtension" from namespace "AppBundle\Twig". Did you
forget a "use" statement for another namespace?" at
/home/travis/var/cache/prod/appProdProjectContainer.php line 2881
{"exception":"[object]
(Symfony\Component\Debug\Exception\ClassNotFoundException(code:
0): Attempted to load class \"AppExtension\" from namespace
\"AppBundle\Twig\".\nDid you forget a \"use\" statement for another
namespace? at
/home/travis/var/cache/prod/appProdProjectContainer.php:2881)"} []
[2017-01-19 06:35:03] request.CRITICAL: Exception thrown when handling
an exception
(Symfony\Component\Cache\Exception\InvalidArgumentException: Cache
directory is not writable
(/home/travis/var/cache/prod/pools/CtBqbs+VrF) at
/home/travis/var/cache/prod/classes.php line 1194)
{"exception":"[object]
(Symfony\Component\Cache\Exception\InvalidArgumentException(code:
0): Cache directory is not writable
(/home/travis/var/cache/prod/pools/CtBqbs+VrF) at
/home/travis/var/cache/prod/classes.php:1194)"} []
Also, it's worth mentioning that that a fresh, empty project made from the command symfony new project does work.
*EDIT
I have consulted these Symfony docs. I have tried every way of clearing cache that I could find.
*EDIT
Here is services.yml
services:
app.twig_extension:
class: AppBundle\Twig\AppExtension
arguments: ["#doctrine.orm.entity_manager", "#security.token_storage"]
public: false
tags:
- { name: twig.extension }
It seems that there is an access problem for your web server.
Check user which launching apache on Centos by
# egrep -i '^user|^group' /etc/httpd/conf/httpd.conf
It should return apache
Then give the good privilege to /home/travis directory:
Option 1: You could have a look on Stack Echange / AskUbuntu and adapt it with apache user instead of www-data
Option 2: With first option, if you've created a folder, Apache cannot write to it. This can be "fixed" by setting umask 0007 and adding yourself (travis) to the Apache group, so that newly created files and folders are writeable by the group.
Option 2 is better if ou have enough privileges to change mask.
Try to clear cache :
php bin/console cache:clear --env=prod
and set files permissions :
chmod -R 777 var/cache
chmod -R 777 var/logs
chmod -R 777 var/sessions
hope this help you.
I had faced the same problem before once. You will have to complete remove the vendor folder
rm -R vendor/
and freshly install all the dependencies again.
php composer.phar install
This will resolve the issue.

Symfony2 - Attempting to view my site in prod environment results in a blank screen; no errors/warnings in dev

Cross-posted from the official Symfony Google Group because time is an issue:
I'm in the final push to upload my site to my host. Everything runs fine in the dev environment - no errors, no warnings. When I attempt to access it in prod (localhost/web/app.php/), I get a blank screen. I attempted to clear the cache, to see if that would help, but got the following error:
$ app/console cache:clear --env=prod
[Symfony\Component\DependencyInjection\Exception\InvalidArgumentException]
The parameter "kernel.trusted_proxies" must be defined.
I can clear the dev cache without issue.
Please help.
You'll need to add trusted_proxies to your config, even if it is blank.
Within: app/config/config.yml add:
framework:
trusted_proxies: ~
You'll also likely want to delete your cache files (app/cache/prod) and then run your console cache clear ($ app/console cache:clear --env=prod)

Getting 'CG\Proxy\InterceptorLoaderInterface' error with JMS Bundle in symfony 2

I am trying to install symfony2 JMS DI Extra bundle.
But i keep getting this error
Fatal error: Interface 'CG\Proxy\InterceptorLoaderInterface' not found
in
/home/xxxxx/public_html/XXXX/Symfony/vendor/bundles/JMS/AopBundle/Aop/InterceptorLoader.php
on line 30
I have found the solution here
https://github.com/schmittjoh/JMSAopBundle/issues/7
But could not able to understand where to fix the path
I think that's cg-library is missing. Open a command prompt into your Symfony vendor folder and issue:
git clone https://github.com/schmittjoh/cg-library.git cg-library
The add cg-library into your deps file:
[cg-library]
git=https://github.com/schmittjoh/cg-library.git
target=/cg-library

Keep getting 'You have requested a non-existent service "test.client"' in Symfony2 Beta3

I'm trying to setup a unit test but whenever I run "phpunit -c app" I get this error:
Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "test.client".
The code in my test case is just:
public function testNonAuthenticatedPathsIndex()
{
$client = $this->createClient();
}
If I don't make the call to createClient everything runs correctly. I've checked AppKernel.php to make sure the FrameworkBundle (I believe that's where this service is defined) is definitely still in there and it is.
I'm a bit confused as to what might be causing this as I've managed to do this kind of thing before.
Thanks for any help.
Have you enabled the framework.test option in config_test.yml?
framework:
test: ~
In phpunit.xml you should have env variable like:
<env name="APP_ENV" value="test"/>
I had this problem with symfony version 3.3.13.
The config_test.yml file was fine, but I did the same mistake.
I solved adding the <server name ="APP_ENV" value="test" /> option under php in the phpunit.xml file
composer require symfony/browser-kit
The definition test.client depends upon AbstractBrowser::class presence
I had same issue with remote builds of my project. This issue was connected with empty symfony.lock file in the root of my project. This file is for preventing symfony recipes execution twice. But my symfony.lock was corrupted and empty so framework-bundle executed it's recipe and replaced my APP_ENV variable in phpunit.xml.dist from test to dev. The reason why it happened was repositories node in composer.json (https://github.com/symfony/flex/issues/347)
I'm fixing this situation by adding dependencies in symfony.lock by my hands

Categories