Symfony2 Memcached - LeaseWeb/LswMemcacheBundle Not work in development mode - php

Am using Symfony2 in my project and i added this bundle "LeaseWeb/LswMemcacheBundle" to use memcahced , the problem that its work fine for me in the production mode and in development mode show me this error :
ContextErrorException: Catchable Fatal Error: Argument 3 passed to
Lsw\MemcacheBundle\DataCollector\MemcacheDataCollector::addClient()
must be an instance of
Lsw\MemcacheBundle\Cache\LoggingMemcacheInterface, instance of
Lsw\MemcacheBundle\Cache\AntiDogPileMemcache given, called in
/home/www/project/app/cache/dev/appDevDebugProjectContainer.php on
line 2166 and defined in
/home/www/project/vendor/leaseweb/memcache-bundle/Lsw/MemcacheBundle/DataCollector/MemcacheDataCollector.php
line 40
And here is my configuration :
lsw_memcache:
session:
client: default
clients:
default:
hosts:
- { dsn: localhost, port: 11211 }
Any one can help with this ?
Thank you in advance ...

I cant see any problem with your configuration.
The error message should not occur with the current version of the bundle.
Which Version of the bundle do you use?

This is a reported issue in the symfony bundle, until now is not fixed
https://github.com/LeaseWeb/LswMemcacheBundle/issues/41

This is solved, its was need libmemcache version 1.0.10 or higher and install last version of memcahced .

Related

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

I keep getting this problem everytime i try to migrate using the commandline: php bin/console make:migration
or even doctrine:migration status
when i try the doctrine:migration:sync-metadata-storage as they tell me I still get the same error message.
I'm currently learning symfony and have been following a guide but I get this problem somehow
Symfony 4.4
php 7.2
Try changing the DATABASE_URL in .env from
DATABASE_URL=mysql://root:#127.0.0.1:3306/testtest?serverVersion=10.4.11
to
DATABASE_URL=mysql://root:#127.0.0.1:3306/testtest?serverVersion=mariadb-10.4.11
Symfony documentation suggest specifying the version number but not the database type
"There are more options in config/packages/doctrine.yaml that you can configure, including your server_version (e.g. 5.7 if you're using MySQL 5.7), which may affect how Doctrine functions."
https://symfony.com/doc/current/doctrine.html
Original Answer: https://github.com/doctrine/DoctrineMigrationsBundle/issues/337#issuecomment-645390496
For MariaDB you will need the full semver compat version: Major.Minor.Patch. By executing mysql --version, you will get the correct version you are currently running.
For me was enough prefixing the server version with mariadb-x.x.x. It fixed the issue.
"If you are running a MariaDB database, you should prefix the serverVersion with mariadb- (ex: mariadb-10.2.12)."
https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
It works if I change the DATABASE_URL in .env
From:
DATABASE_URL=mysql://root:#127.0.0.1:3306/testtest?serverVersion=10.4.11
To:
DATABASE_URL=mysql://root:#127.0.0.1:3306/testtest?serverVersion=mariadb-10.4.11
In my case, it works when I remove : ?serverVersion=5.2 , from the url.
you have to change the serverVersion=5.7 in .env to serverVersion=mariadb-10.4.8
I ran into the same issue after upgrading to Doctrine migrations 3
Seems that a lot of stuff has changed including the table name where migration versions are stored :(
So I updated config/packages/doctrine_migrations.yaml, created a new (blank) migration, cleared the cache (just in case) and everything went just fine :)
doctrine_migrations:
migrations_paths:
# namespace is arbitrary but should be different from App\Migrations
# as migrations classes should NOT be autoloaded
'DoctrineMigrations': '%kernel.project_dir%/src/Migrations'
storage:
# Default (SQL table) metadata storage configuration
table_storage:
table_name: 'migration_versions'
version_column_name: 'version'
version_column_length: 1024
executed_at_column_name: 'executed_at'
execution_time_column_name: 'execution_time'
BTW. Docs are up to date ;) https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
Symfony 5.1
if you got:
Invalid platform version "maridb-10.4.13" specified. The platform version has to be specified in the format: "<major_version>.<minor_version>.<patch_version>".
just do one of
config/doctrine.yaml
doctrine:
dbal:
server_version: 'mariadb-10.4.13'
or in configuration file
.env
DATABASE_URL=mysql://databaseUsername:UserPassword#localhost:3306/databaseName?serverVersion=mariadb-10.4.13
I've added serverVersion=mariadb-10.4.11 in the database URL string, and it worked.
Remove the server version in .env file
DATABASE_URL=mysql://root:#127.0.0.1:3306/DB_Name
for me it worked with me when i removed "?serverVersion=5.7" in .env file
from: DATABASE_URL="mysql://root:#127.0.0.1:3306/centre?serverVersion=5.7"
to DATABASE_URL="mysql://root:#127.0.0.1:3306/centre"
I have the same problem it is because of the new version of doctrine migration 3.0
php bin/console debug:config DoctrineMigrationsBundle
https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
I temporary resolved this problem by modifying the file: /vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php
changed method diffColumn:
// This is a very nasty hack to make comparator work with the legacy json_array type, which should be killed in v3
if ($this->isALegacyJsonComparison($properties1['type'], $properties2['type'])) {
array_shift($changedProperties);
$changedProperties[] = 'comment';
}
//////////////////////////////////////////////////////////////////
// This is my change for fix problem//////////////////////////////
//////////////////////////////////////////////////////////////////
if ($properties1['default'] === 'NULL') {
$properties1['default'] = null;
}
if ($properties2['default'] === 'NULL') {
$properties2['default'] = null;
}
/////////////////////////////////////////////////////////////////
// Null values need to be checked additionally as they tell whether to create or drop a default value.
// null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation.
if (($properties1['default'] === null) !== ($properties2['default'] === null)
|| $properties1['default'] != $properties2['default']) {
$changedProperties[] = 'default';
}
https://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
follow the instructions to the letter
composer require doctrine/doctrine-migrations-bundle
php bin/console doctrine:migrations:generate
php bin/console doctrine:migrations:status --show-versions
php bin/console doctrine:migrations:migrate
everything worked for me
If you upgraded doctrine/doctrine-migrations-bundle to version 3, this solution worked for me:
Just run: php bin/console doctrine:migrations:sync-metadata-storage
Same problem here..
I "sloved" it but dont try this at home!
I removed these lines in
vendor\doctrine\migrations\lib\Doctrine\Migrations\Metadata\Storage\TableMetadataStorage.php
start on line 191
$expectedTable = $this->getExpectedTable();
if ($this->needsUpdate($expectedTable) !== null) {
throw MetadataStorageError::notUpToDate();
}
Then run make:migration and migrations:migrate.
After success migration paste the function back.
In your .env file you can use a default settings pattern:
DATABASE_URL=mysql://db-username:db-password#127.0.0.1/db-name
But you need to configure server_version in doctrine.yaml
An example configuration can look like this:
doctrine:
dbal:
driver: 'pdo_mysql'
server_version: 'mariadb-10.5.8-focal'
charset: UTF8
url: '%env(resolve:DATABASE_URL)%'
In my case, it's mariadb-10.5.8-focal.
just execute this command
symfony console cache:clear
it solve the problem for me a
In my case (MariaDB 10.7.3) setting ?serverVersion=mariadb-10.7.3 didn't help.
I had to uninstall MariaDB 10.7.3 and install MySQL Community 8.0.28 instead, and then changed DATABASE_URL to ?serverVersion=8.0.28
Only switching from MariaDB to MySQL Community fixed this problem for me.
change
DATABASE_URL=mysql://root:#127.0.0.1:3306/testtest?serverVersion=10.4.11
To
DATABASE_URL=mysql://root:#127.0.0.1:3306/testtest?serverVersion=mariadb-10.4.11
in your .env file at the database line remove everything after the database name. This should fix the problem!
I tried all of these solutions. In Symfony 6.x version all of these solutions aren't working. But I removed symfony/web-profiler-bundle package and everything is fine now. Actually I don't need any profiler. Thanks symfony. I hope you spend my another days in the future.
I will escape from PHP because of symfony framework in near future.

Symfony 2: MemcachePool not found

I was upgrading my Symfony 2 project, which works with the lws_memcache Bundle.
Now my I get the following error:
ClassNotFoundException in LoggingMemcache.php line 4:
Attempted to load class "MemcachePool" from the global namespace.
Did you forget a "use" statement?
The File lies in the vendor of the lws_memcache Bundle, so I can't change the code.
My memcached Server is on the version 1.4.14, the bundle itself is the newest verison.
This is what my IDE (PHPStorm 8) shows me when I hover over the Class \MemcachePool in the vendor code.
Multiple definitions exist for class MemcachePool less... (Strg+F1)
Undefined class: Declaration of referenced class is not found in
built-in library and project files. Multiple declarations: this
version of IDE will have problems with completion, member resolution
and inheritance analysis for all classes that have multiple
definitions in project files (regardless of includes).
Is there something I can do about it?
LswMemcacheBundle bundle is compatible with memcache 3.0.6 or higher. I was having the same error with php-memcache 2.2.x.
Try upgrading your php-memcache to the new one (3.0.8), but first you need to edit the formula and setup the flags brew edit php56-memcache :
. 20 safe_phpize
. 21
+ 22 ENV['MACOSX_DEPLOYMENT_TARGET'] = '10.11'
+ 23 ENV['CFLAGS'] = '-fgnu89-inline'
+ 24 ENV['LDFLAGS'] = '-fgnu89-inline'
+ 25 ENV['CXXFLAGS'] = '-fgnu89-inline'
+ 26
. 27 system "./configure", "--prefix=#{prefix}",
. 28 phpconfig
. 29 system "make"
$ brew uninstall homebrew/php/php56-memcache
$ brew install homebrew/php/php56-memcache --devel
Then restart php-fpm + nginx.
Make sure your config file has a memcache session pool defined.
Try rebooting the server.
I had the same issue when installing LwsMemcache in my symfony project. I received the exact same error on production as the one above, but on my dev box, It was a different error (can't remember what it said), but had to do with php5 and memcache not working together.
restarting the services for nginx and php5-fpm did not work. I had to reboot and it works fine.

Laravel Homestead error: Failed to create host-only adaptor

This error occurs with all Vagrant boxes with a private network IP.
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "create"]
Stderr: 0%...
Progress state: E_FAIL
VBoxManage.exe: error: Failed to create the host-only adapter
VBoxManage.exe: error: Code E_FAIL (0x80004005) - Unspecified error (extended info not available)
VBoxManage.exe: error: Context: "int __cdecl handleCreate(struct HandlerArg *,int,int *)" at line 66 of file VBoxManageHostonly.cpp
I've tried composer install, manual install, downgrading virtualbox to 4.2.x - nothing works.
Please help!
Thanks
Turns out to be a common 'issue' on Windows 7 hosts with any vagrant box with a private network.
The Windows host user account needs to have admin rights.
There's a known bug # 14040 in VirtualBox 5. Updating to Vbox 5.0.9 worked for me.
I had the same problem using virtualbox 5.0.26 when I updated to 5.1.4 it worked! am using vagrant version 1.9.1

Symfony and Azure Distribution Bundle - assets in Azure

I am trying to deploy an existing Symfony 2.1 application to Azure. For this I am using the Azure Distribution Bundle, and I am trying to deploy assets to Azure as documented here.
However, I am getting an error when doing windowsazure:package to create the package:
Catchable Fatal Error: Argument 2 passed to WindowsAzure\DistributionBundle\Deployment\Assets\BlobStrategy::__construct() must be an instance of WindowsAzure\Blob\BlobRestProxy, none given, called in C:\IGPR\igpr\app\cache\azure\appAzureDebugProjectContainer.php on line 2361 and defined in C:\IGPR\igpr\vendor\beberlei\azure-distribution-bundle\WindowsAzure\DistributionBundle\Deployment\Assets\BlobStrategy.php line 35
Here is the relevant section of my config.yml:
windows_azure_distribution:
...
services:
blob:
default: UseDevelopmentStorage=true
azureprod: DefaultEndpointsProtocol=http;AccountName=myaccountname;AccountKey=MyVeryLongAccOUntKeY==
assets:
type: blob
connection_name: azureprod
Any ideas? Seems that the Blob proxy cannot be created. I get the same error if I try to use the local development storage.
The bundle is installed via Composer.
Looks like this was a bug in the Azure Distribution Bundle, which the maintainer has now fixed.

FOSRest gives fatal error in symfony 2

i am trying to install FOSRest & FOSRestBundle
initially , i have specified following settings in the deps
[FOSRest]
git=git://github.com/FriendsOfSymfony/FOSRest.git
target=fos/FOS/Rest
[FOSRestBundle]
git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
But that cause me into following error when i access http://localhost/Symfony/web/app_dev.php/
Fatal error: Declaration of
FOS\RestBundle\Routing\Loader\RestRouteLoader::setResolver() must be
compatible with that of
Symfony\Component\Config\Loader\LoaderInterface::setResolver() in
/home/logicase/public_html/Symfony/vendor/bundles/FOS/RestBundle/Routing/Loader/RestRouteLoader.php
on line 29
After that i tried following setting to make to the master branch and above error remains the same
[FOSRest]
git=git://github.com/FriendsOfSymfony/FOSRest.git
target=fos/FOS/Rest
version=origin/2.0
[FOSRestBundle]
git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
version=origin/2.0
and now when i run php ./bin/vendors install
i get following message in console.
Installing/Updating FOSRest 5eb800bd63ba84e5fc7028386cb66373bc3efafc fatal: ambiguous argument 'origin/2.0': unknown revision or path not
in the working tree. Use '--' to separate paths from revisions
Installing/Updating FOSRestBundle c11ab9d990a1e0e979b1c8ab72cc9793b4b2dcb5 fatal: ambiguous argument
'origin/2.0': unknown revision or path not in the working tree.
I tried following settings for FOSRest which solved my problem for symfony 2
[FOSRest]
git=git://github.com/FriendsOfSymfony/FOSRest.git
target=fos/FOS/Rest
version=origin/0.6
[FOSRestBundle]
git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
target=bundles/FOS/RestBundle
As you can see, there is no 2.0 branch : https://github.com/FriendsOfSymfony/FOSRestBundle/branches https://github.com/FriendsOfSymfony/FOSRest/branches The installation documentation does not talk about it. You should just remove the version lines.

Categories