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
Related
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'));
I'm new with symfony2 and i wnat to test my app using behat but when I followed the official install in this link http://docs.behat.org/en/latest/cookbooks/1.symfony2_integration.html#installing-and-enabling-symfony2-extension
i got this error :
[Behat\Behat\Context\Exception\ContextNotFoundException]
FeatureContext context class not found and can not be used.
it was just after the first line and when i ran the bin/behat command.
When using the Symfony2Extension, you are responsible for handling the autoloading. Make sure the FeatureContext class can be autoloaded by changing your composer.json autoload configuration and running composer dump-autoload.
When I try to install HWIOAuthBundle I get the following error:
Fatal error: Class 'hwi\oauthbundle\HWI\Bundle\OAuthBundle' not found in C:\xampp\htdocs\prjectName\app\AppKernel.php on line 24
I have reference to documentation, after running the composer , i do get hwi package downloded with path as C:\xampp\htdocs\prjectName\vendor\hwi\oauth-bundle\HWI\Bundle\OAuthBundle but when i include it in the AppKernel.php file as
24th line of AppKernel.php is:
new hwi\oauth-bundle\HWI\Bundle\OAuthBundle(),
As the doccumentation says you should register this bundle to appKernel.php by adding
new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
instead of
new hwi\oauth-bundle\HWI\Bundle\OAuthBundle(),
The path added to the appKernel.php is not the exact path of the bundle where it is added but the namespace + class name of the main bundle's class (which extends Bundle).
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
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(),