Symfony 2: LiipDoctrineCacheBundle not found in AppKernel - symfony

I've installed this bundle LiipDoctrineCacheBundle in vendor\bundles\ folder of my website.
Then, as usual, I added in autoload.php a new entry in the array namespace:
'Liip' => __DIR__.'/../vendor/bundles',
And I registered this new bundle in the bundles' array of AppKernel.php:
new Liip\DoctrineCacheBundle\LiipDoctrineCacheBundle(),
But weirdly I get this error message:
Fatal error: Class 'liip\DoctrineCacheBundle\LiipDoctrineCacheBundle' not found in C:\workspace\LHN\app\AppKernel.php on line 26
It's like if Symfony cannot retrieve the bundle in the nameSpace...
So I've tried by changing the case of the bundle key: 'Liip'==> 'liip'
And I've also tried with the fully path location:
__DIR__.'/../vendor/bundles' ==> C:\workspace\mySite\vendor\bundles
Any idea?
Thks
Symfony: 2.0.9
Liip bundle: master

You are probably using the wrong name for the bundle class.
i think it should be
new Liip\LiipDoctrineCacheBundle\LiipDoctrineCacheBundle()
or
new liip\LiipDoctrineCacheBundle\LiipDoctrineCacheBundle()
not sure if the first "L" is capital or not in your vendor/bundles/ source

Thanks to Laurynas's comment I understood my problem: the source bundle path was wrong
vendor\bundles\liip\LiipDoctrineCacheBundle
instead of
vendor\bundles\Liip\DoctrineCacheBundle
The origin of this issue is that I made a mistake in the deps file (where the git location, the version and the target directory are defined) by setting the target property to /bundles/liip/LiipDoctrineCacheBundle instead of to /bundles/Liip/DoctrineCacheBundle.
My bad... ;-)
Correct dep block:
[LiipDoctrineCacheBundle]
git=https://github.com/liip/LiipDoctrineCacheBundle.git
target=/bundles/Liip/DoctrineCacheBundle
version=master

Related

symfony fatal error after removing bundle

I created a bundle named UserBundle and when I needed to remove it I did this exacly :
Unregister the Bundle in the AppKernel
Remove Bundle Configuration
2.1 Remove Bundle Routing
2.2 Remove Bundle Configuration
Remove the Bundle from the Filesystem
3.1 Remove Bundle Assets
Remove Integration in other Bundles
but when I try to exec soms command this is what I Get :
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Bundle "UserBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in #UserBundle/Resources/config/s
ervices.yml (which is being imported from "C:\xampp\htdocs\MT\app/config\config.yml"). Make sure the "UserBundle/Resources/config/services.yml" bundle is correctly registered an
d loaded in the application kernel class. If the bundle is registered, make sure the bundle path "#UserBundle/Resources/config/services.yml" is not empty.
[InvalidArgumentException]
Bundle "UserBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file?
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:
[Symfony\Component\Config\Exception\FileLoaderLoadException]
Bundle "UserBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file? in #UserBundle/Resources/config/services.yml (which is being imported from "C:\xampp\htdocs\MT\app/config\config.yml").
Make sure the "UserBundle/Resources/config/services.yml" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "#UserBundle/Resources/config/services.yml" is not empty.
When I Refresh the server 'http://127.0.0.1/mt/web/' I get :
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Bundle "UserBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file?' in C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php:198 Stack trace: #0 C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Kernel.php(232): Symfony\Component\HttpKernel\Kernel->getBundle('UserBundle', false) #1 C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Config\FileLocator.php(51): Symfony\Component\HttpKernel\Kernel->locateResource('#UserBundle/Res...', NULL, false) #2 C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php(147): Symfony\Component\HttpKernel\Config\FileLocator->locate('#UserBundle/Res...', 'C:\xampp\htdocs...', false) #3 C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php(101): Symfony\Component\Config\Loader\FileLoader-> in C:\xampp\htdocs\MT\vendor\symfony\symfony\src\Symfony\Component\Config\Loader\FileLoader.php on line 179
In C:\xampp\htdocs\MT\app\config\config.yml you may have something like:
imports:
- { resource: #UserBundle/Resources/config/services.yml }
and possibly a configuration section related to the user bundle, i.e.
user_bundle:
...
You have to manually remove both to make everything working again.
Can you check if you use this bundle in app/config/service.yml
If it's not working, try to search with your IDE (integrated development environment) your bundle inside your project. If you find some results, just remove them.
Clear the cache
Try to clear cache manually by removing those folders : "var\cache\dev" and "var\cache\prod" for Symfony 3.x or "app\cache\dev" and "app\cache\prod" for Symfony 2.x .

Creating a Bundle outside src/

I have created a bundle with symfony 2.3 but in this case (cause my teacher asked to me) outside src/ folder so I have ../symfony/fuentes/NameBundle instead of ../symfony/src/NameBundle. The new line appears in AppKernel and my new bundle appears on routing.yml, but when I try to launch the server
Bundle generation
Generating the bundle code: OK
Checking that the bundle is autoloaded: FAILED
Confirm automatic update of your Kernel [yes]?
Enabling the bundle inside the Kernel: OK
Confirm automatic update of the Routing [yes]?
Importing the bundle routing resource: OK
The command was not able to configure everything automatically.
You must do the following changes manually.
- Edit the composer.json file and register the bundle
namespace in the "autoload" section:
I have edit autoload and tried a lot of things (looking for here) but it appears the same error always.
C:\Users\Akenateb\Documents\UOC\AULAMENTOR\Symfony>php app/console server:run 127.0.0.1:8080
PHP Fatal error: Class 'AulaMentor\ExdosBundle\AulaMentorExdosBundle' not found in C:\Users\Akenateb\Documents\UOC\AULAMENTOR\Symfony\app\AppKernel.php on line 20
Can someone help me? I'm really stuck with it.
Thanks in advance.
First of all I want to thanks to the people who has answered. Here is what we have to do if we want to create a bundle outside 'src' folder, for example in 'fuentes' > '..Symfony/fuentes'.
If you have create with 'generate:bundle' I suggest you accept when the generator ask you if you want to create the complete structure, if you have create a bundle with generator goto step 3.
1- Make sure you have registered bundle in AppKernel and It exists there a line like this:
new YourProject\NameprojectBundle\YourProjectNameprojectBundle(),
2- Make sure you have adding a route to your app/config/routing and 'routing.yml' has you new bundle route, like this (you can add a prefix to your url, in this case fuentes):
your_project_name:
resource: "#YourProjectNameprojectBundle/Resources/config/routing.yml"
prefix: /fuentes
3- We edit 'app/autoload.php' and we add this line:
$loader->add('YourProject',realpath(__DIR__.'/../fuentes'));
Finally we can update assets doing with command line:
php app/console assets:install web
Hope it helps to someone.
Best Regards.
Do exactly as said in the comment:
Edit the composer.json file and register the bundle namespace in the "autoload" section
The src folder is automatically loaded using PSR convention. If you set classes outside of the src folder, they have to be declared as well.
In your composer.json file you can add another element in the autoload section. Here's an example that I think will work for your use case:
"autoload": {
"psr-0": {
"NameBundle\\": "fuentes/",
"": "src/"
}
},
Here's how to add simply another bundle outside your Symfony project, when we don't want to mess up with composer.json file.
The 2 first points are the same as in the Michael J.'s answer. Now to the 3rd point:
Say, we need to add a OurCompany/SomeBundle residing in the other project, which relative path is ../../OtherProject/src/OurCompany/SomeBundle to CurrentProject/app dir.
So we add this bundle to the CurrentProject application this way:
$loader->add('OurCompany\\SomeBundle', realpath(__DIR__.'/../../OtherProject/src'));
PLEASE NOTICE how the slashes and backslashes should be used (the remaining / or \ at the end doesn't matter, it's smart enough to figure it out).
And for the whole namespace to be loaded (all bundles namespaces in the other project available in CurrentProject):
$loader->add('OurCompany', realpath(__DIR__.'/../../OtherProject/src'));

Symfony2 Solarium Class 'Solarium_Plugin_Abstract' not found

I am using https://github.com/nelmio/NelmioSolariumBundle and I am trying to conect with solarium y my symfony2 application.
I have installed solarium with the composer.json but then I get
Class 'Solarium_Plugin_Abstract' not found in .../vendor/bundles/Nelmio/SolariumBundle/Logger.php on line 12
I don't understand why in the Logger there is:
use Solarium_Plugin_Abstract
But in the folders I find:
myproject/vendor/solarium/library/Solarium/Plugin/Abstract.php
I have declared in my autoload.php
'Solarium' => DIR.'/../vendor/solarium/library',
Should't be: use Solarium/Pluguin/Abstract ?
What I am doing wrong?

Install JMSSerializerBundle

I installed FOSRestBundle but it needs JMSSerializerBundle.
I added in my deps the next lines:
[JMSSerializerBundle]
git=git://github.com/schmittjoh/JMSSerializerBundle.git
target=bundles/JMS/SerializerBundle
Here it explains how to do it: http://jmsyst.com/bundles/JMSSerializerBundle/master/installation
but when I try $php bin/vendors install it shows me an error:
[InvalidArgumentException]
The service definition "jms_serializer.serializer" does not exist.
You should comment the new FOS\RestBundle\FOSRestBundle(), line in AppKernel.php in the registerBundles() method. Then install the JmsSerializerBundle and after that you should decommend that line and register the JsmSerializerBundle.
The manual says it to register the bundle with the kernel:
new JMS\Serializer\JMSSerializerBundle($this),
but the installer create the folder: vendor/bundles/JMS/SerializerBundle
so, it must be added the next line to the AppKernel.php instead of the other:
new JMS\SerializerBundle\JMSSerializerBundle($this),
Did you also do the following steps from the manual? Sounds to me like you didn't add the line
new JMS\Serializer\JMSSerializerBundle($this)
to AppKernel.php

How to install a Symfony 2.0 Bundle from Zip file

I tried installing the FixturesBundle as described in http://symfony.com/doc/2.0/bundles/DoctrineFixturesBundle/index.html but my proxy wont let me out.
So I went to https://github.com/doctrine/data-fixtures and download a zip from the latest commit.
I unzipped into the vendor directory and renamed it to doctrine-fixures. I edited the autoload.php and AppKernel.php files as described in the tutorial.
When I run:
php app\console doctrine:fixtures:load
I get the following message:
PHP Fatal error: Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesB
undle' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on
line 20
Fatal error: Class 'Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle
' not found in C:\NetbeansProjects\route_rest_service\app\AppKernel.php on line
20
Is there a way to run the installation of bundle pointing it to a zip file?
I´m running Symfony 2.0.9 on Windows 7.
Seems like the doctrine bundle has been moved outside of Symfony scope back to Doctrine.
Please, use https://github.com/doctrine/DoctrineFixturesBundle
I had the same problem and this is how i successfully solved it. I started to download this files data-fixtures and DoctrineFixturesBundle, unzipped both into /vendor/doctrine and created this folder structure:
vendor
- doctrine
- doctrine-fixtures-bundle
- Doctrine
- Bundle
- FixturesBundle
DoctrineFixturesBundle.php
..other files...
vendor
- doctrine
- data-fixtures
- lib
- test
composer.json
..other files...
Then i edited the AppKernel.php and added
public function registerBundles(){
.....
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
.....
}
Edited the composer.json located in the root of the project and added this 2 lines:
"Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
"Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"
Mine, now look like this:
{
"autoload": {
"psr-0": {
"": "src/",
"Doctrine\\Bundle\\FixturesBundle": "vendor/doctrine/doctrine-fixtures-bundle",
"Doctrine\\Common\\DataFixtures": "vendor/doctrine/data-fixtures/lib"
}
}
}
afterwards execute composer dump-autoload -o to recreate the classmap. All this was thanks to the users Wouter J and nifr that answered my question How to install DoctrineFixturesBundle offline
Happy coding!
Yes, it's true that Doctrine is being moved away from the Symfony namespace (see here).
So if you're using the Symfony standard distribution you download from the website (without using git), and you want to have the FixturesBundle installed manually, you have to download the doctrine-fixtures library from here, extract the zip into
YourProject/vendor/doctrine-fixtures
Download the FixturesBundle from here, and extract it in
YourProject/vendor/bundles/Doctrine/Bundle/FixturesBundle
Then you have to register the library's namespace, do it by adding
'Doctrine\\\\Common\\\\DataFixtures' => \__DIR\__.'/../vendor/doctrine-fixtures/lib',
in your autoload.php.
In addition, you'll have to register the Doctrine's namespace, because some part of your application will be using the DoctrineBundle shipped from the Symfony namespace, but the new downloaded FixturesBundle will be using the new Doctrine's namespace, so to make it work, in your autoload.php add the following line (taking care you do it before the Doctrine namespace, remember that more specific rules go first!)
'Doctrine\\\\Bundle' => \__DIR\__.'/../vendor/bundles',
So all you have to do now is to register the new bundle in your AppKernel.php writing
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),

Resources