I have created a fresh Symfony project and I keep getting this "DoctrineMigrationsBundle requires DoctrineBundle to be enabled." error and cant get rid of it. Apparently I'm the only one on the planet who gets this error as google wasn't too helpful.
in the config/bundles.php file I have the following which should "Enable" DoctrineBundle but I'm missing something and cant tell what it is.
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
];
I had the same error,
for some reason, the yaml files that should be inside config/packages were not committed to git.
You can do the following:
create a new symfony project
copy the config/packages folder from the fresh install to my project
copy the /bin folder as well if it is also missing
add these 2 line to .gitignore
!/bin/
!/config/packages/*
(Adding the !/bin to .gitignore is not related to this error, but it should not be ignored anymore as of symfony 6 and is the solution to fix this other error: Script cache:clear returned with error code 1
Could not open input file: ./bin/console). when you install a symfony project from git.
Related
I did a Laravel 5.5.43 installation this morning with the following Composer command:
composer create-project laravel/laravel project-name
I then ran the following command in the project folder to install Laravel Collective:
composer require "laravelcollective/html":"^5.4.0"
I then added the following under providers in config/app.php:
Collective\Html\HtmlServiceProvider::class,
And I added the following under aliases in config/app.php:
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
After that, I wanted to create custom form components, so I ran the following Artisan command:
php artisan make:provider FormServiceProvider
And in that new provider file, I added the following line to the boot method:
Form::component('customText', 'components.form.text', ['name', 'value' => null, 'attributes' => []]);
Lastly, I added the following to providers in config/app.php:
App\Providers\FormServiceProvider::class,
When I do that though and refresh the Laravel instance from the browser, I get the following error:
Class 'App\Providers\Form' not found
However, if I add the following at the top of the FormServiceProvider.php file, then it works:
use Collective\Html\FormFacade AS Form;
I understand the concept of namespaces and why that makes the Form::component method in the boot method in the file properly work, but what I don't get is why I need to add that use line to the file at all.
Isn't the 'Form' => Collective\Html\FormFacade::class, line in the aliases array in the app.php file supposed to do that for me so I don't need to add the use line to the FormServiceProvider.php at all? What am I missing / doing wrong / not understanding?
Thank you.
I probably should just delete this question, but the simple answer was to add the following at the top of the FormServiceProvider.php file:
use Form;
Thanks.
Run below command:
php artisan config:cache
php artisan cache:clear
Searching using the TNTSearch driver works in a Homestead environment however on production it returns error: the below error,
Symfony\Component\Debug\Exception\FatalThrowableError: Class
'AlgoliaSearch\Version' not found on
vendor/laravel/scout/src/EngineManager.php:31
However my .env has SCOUT_DRIVER=tntsearch and the config file scout.php has:
'driver' => env('SCOUT_DRIVER', 'tntsearch'),
'tntsearch' => [
'storage' => storage_path(),
'fuzziness' => env('TNTSEARCH_FUZZINESS', false),
'fuzzy' => [
'prefix_length' => 2,
'max_expansions' => 50,
'distance' => 2
],
'asYouType' => false,
'searchBoolean' => env('TNTSEARCH_BOOLEAN', false),
]
The problem is that I am not using Algolia search and my composer file has Scout and TNTSearch driver. The search works in my local Homestead environment just not on the production server.
Confirm that SCOUT_DRIVER=tntsearch has been added to your .env file.
For me personally, I had added SCOUT_DRIVER=tntsearch to my local .env file, but not my .env file for the environment with the issue. Don't forget to run php artisan config:clear after adding the env var.
Thanks to #m33bo for pointing me in the right direction!
I worked it out, I had uploaded my project but for some reason the .index file that is needed sync'd but did not work. If this happens to you on live make sure you Git or SVN or whatever the index or run php artisan scout:import App\\Your\\Model
Class 'Illuminate\Html\HtmlServiceProvider' not found laravel 5.0
Simply follow 4 step
1) Go root directory find and edit composer.json - In that file write "illuminate/html": "^5.0" in require array.
2) Goto cmd and goto your folder directory and ** composer update **run this command
3) Next, add your new provider to the providers array of config/app.php:
'providers' => [
'Collective\Html\HtmlServiceProvider',
],
4) Finally, add two class aliases to the aliases array of config/app.php:
'aliases' => [
'Form' => 'Collective\Html\FormFacade',
'Html' => 'Collective\Html\HtmlFacade',
],
After all this finished
Restart your laravel server :-- php artisan serve --port=8880
Now you can use Any Html tag in your view blade
For me, it was a much stupider mistake that I was making (although the provided answer works perfectly for the real issue).
What I was doing was continually editing the wrong composer file. I had one composer file outside of my laravel directory that was obviously not going to make any difference in my application.
When I did all of the recommended updated to the real composer file, everything worked fine.
I follow the instructions at: http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html step by step and have a Mongo server running however when I try to do :
php app/console generate:bundle --namespace=Acme/StoreBundle
I get
Class 'Doctrine\Common\Persistence\Mapping\Driver\FileDriver' not found in /Users/username/Sites/myapp/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/Mapping/Driver/XmlDriver.php on line 37
I am thinking something could be wrong with my parameters.ini file which still mentions MYSQL however the link above did not mention anything about that:
[parameters]
database_driver="pdo_mysql"
database_host="localhost"
database_port=""
database_name="somedb"
database_user="root"
database_password="mypassword"
mailer_transport="smtp"
mailer_host="localhost"
mailer_user=""
mailer_password=""
locale="en"
secret="093faacf47bcdcdcdcdcdc9d152fc8b"
what am I doing wrong?
UPDATE:
I have Doctrine Common downloaded and here is my registerNameSpaces function:
$loader->registerNamespaces(array(
'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
'Sensio' => __DIR__.'/../vendor/bundles',
'JMS' => __DIR__.'/../vendor/bundles',
'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
'Doctrine\\ODM\\MongoDB' => __DIR__.'/../vendor/doctrine-mongodb-odm/lib',
'Doctrine\\MongoDB' => __DIR__.'/../vendor/doctrine-mongodb/lib',
'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
'Monolog' => __DIR__.'/../vendor/monolog/src',
'Assetic' => __DIR__.'/../vendor/assetic/src',
'Metadata' => __DIR__.'/../vendor/metadata/src',
'FOS' => __DIR__.'/../vendor/bundles',
'FOS\\Rest' => __DIR__.'/../vendor/fos',
'JMS' => __DIR__.'/../vendor/bundles',
));
my deps file:
[symfony]
git=http://github.com/symfony/symfony.git
version=origin/2.0
[twig]
git=http://github.com/fabpot/Twig.git
version=v1.8.2
[monolog]
git=http://github.com/Seldaek/monolog.git
version=1.0.2
[doctrine-common]
git=http://github.com/doctrine/common.git
version=2.1.4
[doctrine-dbal]
git=http://github.com/doctrine/dbal.git
version=2.1.7
[doctrine]
git=http://github.com/doctrine/doctrine2.git
version=2.1.7
[swiftmailer]
git=http://github.com/swiftmailer/swiftmailer.git
version=v4.2.0
[assetic]
git=http://github.com/kriswallsmith/assetic.git
version=v1.0.3
[twig-extensions]
git=http://github.com/fabpot/Twig-extensions.git
[metadata]
git=http://github.com/schmittjoh/metadata.git
version=1.0.0
[SensioFrameworkExtraBundle]
git=http://github.com/sensio/SensioFrameworkExtraBundle.git
target=/bundles/Sensio/Bundle/FrameworkExtraBundle
version=origin/2.0
[JMSSecurityExtraBundle]
git=http://github.com/schmittjoh/JMSSecurityExtraBundle.git
target=/bundles/JMS/SecurityExtraBundle
version=origin/1.0.x
[SensioDistributionBundle]
git=http://github.com/sensio/SensioDistributionBundle.git
target=/bundles/Sensio/Bundle/DistributionBundle
version=origin/2.0
[SensioGeneratorBundle]
git=http://github.com/sensio/SensioGeneratorBundle.git
target=/bundles/Sensio/Bundle/GeneratorBundle
version=origin/2.0
[AsseticBundle]
git=http://github.com/symfony/AsseticBundle.git
target=/bundles/Symfony/Bundle/AsseticBundle
version=origin/2.0
[FOSUserBundle]
git=git://github.com/FriendsOfSymfony/FOSUserBundle.git
target=bundles/FOS/UserBundle
version=1.2.0
[FOSRest]
git=git://github.com/FriendsOfSymfony/FOSRest.git
target=fos/FOS/Rest
[FOSRestBundle]
git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
[JMSSerializerBundle]
git=git://github.com/schmittjoh/JMSSerializerBundle.git
target=bundles/JMS/SerializerBundle
[doctrine-mongodb]
git=http://github.com/doctrine/mongodb.git
[doctrine-mongodb-odm]
git=http://github.com/doctrine/mongodb-odm.git
[DoctrineMongoDBBundle]
git=http://github.com/doctrine/DoctrineMongoDBBundle.git
target=/bundles/Symfony/Bundle/DoctrineMongoDBBundle
version=origin/2.0
I also do not see a Driver folder under mapping. I have done a php bin/vendors install --reinstall bu even that doesnt help.
You have to update the three: DBAL, Common and ORM. The three have been released at the same time. So you should use version 2.2 for the 3.
Here is the blog post http://www.doctrine-project.org/blog/doctrine-2-2-final.html
Hope this helps, it worked for me.
Doctrine MongoDB ODM was recently refactored to utilize Doctrine Common's mapping API, which exists in version 2.2+ (see PR's #350 and #370). In turn, both the 2.0 and master branches of the bundle were updated (PR #124).
Based on your deps file, you're using Doctrine Common 2.1.x, which doesn't contain the required classes. You can either bump Common to 2.2, which should be compatible with Symfony 2.0, or lock ODM and the bundle to an earlier commit hash before those PR's were merged. Checking the composer.json files in each repository would be a good way to keep track of these dependencies, even if you aren't using Composer. Hopefully, we'll have tags on the Mongo ODM repositories soon, which should alleviate this headache in the future.
You either don't have Doctrine Common installed, or you don't have it registered in your autoloader. Install it (link: https://github.com/doctrine/common) or redownload the sf2 standard edition.
I wish to install the bundle into my symfony project. However, I am coming across a few issues. Please accept my ignorance if the answer is trivial but I've tried searching for a solution but alas, I've found nothing.
In my deps file, I have:
[doctrine-couchdb]
git=http://github.com/doctrine/couchdb-odm.git
[DoctrineCouchDBBundle]
git=http://github.com/doctrine/DoctrineCouchDBBundle.git
target=/bundles/Symfony/Bundle/DoctrineCouchDBBundle
I run the bin/vendors install command
In my autoload.php file I have:
'Doctrine\\ODM\\CouchDB'=> __DIR__.'/../vendor/doctrine-couchdb/lib',
I've registered the bundle:
new Doctrine\Bundle\CouchDBBundle\DoctrineCouchDBBundle()
When I run php app/console I get the error:
Fatal error: Class 'Doctrine\Bundle\CouchDBBundle\DoctrineCouchDBBundle' not found in /var/www/symfony2.test/app/AppKernel.php on line 22
I've noticed that for MongoDB ODM you have:
[doctrine-mongodb]
git=http://github.com/doctrine/mongodb.git
is there not a doctrine-couchdb repo? Have you used this bundle?
I changed target to
target= /bundles/Doctrine/Bundle/CouchDBBundle
so now looks like this
[DoctrineCouchDBBundle]
git=http://github.com/doctrine/DoctrineCouchDBBundle.git
target=/bundles/Doctrine/Bundle/CouchDBBundle
because I noticed that name space for couchdb bundle is
namespace Doctrine\Bundle\CouchDBBundle;
therefore adding
new Doctrine\Bundle\CouchDBBundle\DoctrineCouchDBBundle()
to AppKernel will fail, if installation location does not match namespace/class_name.
Detailed setup and configuration here DoctrineCouchDBBundle Git Hub Issue Log
For those that are new to Symfony 2 bundling architecture, you probably wonder what configuration keys are mandatory and available for bundles. Info can be obtained from:
bundle_dir/bundle_name/.../configuration.php
Update :
1.) Check that you also have installed and autoloaded Doctrine\CouchDB
2.) in your git installation
target=/bundles/Symfony/Bundle/DoctrineCouchDBBundle should probably be
target=/bundles/Doctrine/Bundle/DoctrineCouchDBBundle (notice Symfony => Doctrine)
3.) Then change
'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
to
'Doctrine' => array(__DIR__.'/../vendor/doctrine/lib', __DIR__.'/../vendor/bundles'),
Off the top of my head I'd assume either these things:
1.) Cache
2.) 'Doctrine\\ODM\\CouchDB'=> __DIR__.'/../vendor/doctrine-couchdb/lib',
should be above any higher level namespaces ('Doctrine', 'Doctrine\Common')
so it should look like this:
'Doctrine\\ODM\\CouchDB'=> __DIR__.'/../vendor/doctrine-couchdb/lib',
'Doctrine\\DBAL' => __DIR__.'/../vendor/doctrine-dbal/lib',
'Doctrine' => __DIR__.'/../vendor/doctrine/lib',
3.) some configuration missing in config.yml