I have a problem with APCu and PHP7 again.
Here is my conf.
framework:
validation:
cache: validator.mapping.cache.doctrine.apc
serializer:
cache: serializer.mapping.cache.apc
doctrine:
orm:
metadata_cache_driver: apcu
result_cache_driver: apcu
query_cache_driver: apcu
Website works ok, but when I send a form, I always get this error:
[2016-06-29 09:17:12] request.CRITICAL: Uncaught PHP Exception
Symfony\Component\Debug\Exception\UndefinedFunctionException:
"Attempted to call function "apc_fetch" from namespace
"Doctrine\Common\Cache"." at
ROUTE_TO_PROJECT/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php
line 41 {"exception":"[object]
(Symfony\Component\Debug\Exception\UndefinedFunctionException(code:
0): Attempted to call function \"apc_fetch\" from namespace
\"Doctrine\Common\Cache\". at
ROUTE_TO_PROJECT/vendor/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php:41)"}
[]
here is my composer:
"require": {
"php": ">=5.5.9",
"symfony/symfony": "3.0.*",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "^2.8",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"knplabs/knp-paginator-bundle": "^2.5",
"liip/imagine-bundle": "^1.5",
"jms/serializer-bundle": "^1.1",
"symfony/assetic-bundle": "^2.8",
"gopay/payments-sdk-php": "^1.1",
"knplabs/knp-snappy-bundle": "~1.4",
"friendsofsymfony/user-bundle": "~2.0#dev"
Why is Symfony call apc_fetch instead apcu_fatch?
In previous versions of APCu, the APC module and functions were provided as part of the library.
In the most recent (PHP 7) versions of APCu, backward compatible APC is a separate extension.
This is my solution:
services.yml
serializer.mapping.cache.apcu:
class: Doctrine\Common\Cache\ApcuCache
confing_prod.yml
serializer:
cache: serializer.mapping.cache.apcu
Idk if this solution is ok, but looks like it works. So if you know better solution, I would like to use it.
You can get apcu working with symfony validation using the doctrine cache wrapper
config.yml
validation:
cache: validator.mapping.cache
services.yml
doctrine.apcu.cache:
class: Doctrine\Common\Cache\ApcuCache
validator.mapping.cache:
class: Symfony\Component\Validator\Mapping\Cache\DoctrineCache
arguments: ['#doctrine.apcu.cache']
Related
I use PHP8, Symfony 5.2 and Doctrine 3.0 in my project,
But the PHP 8 attributes, allowed since Doctrine 2.9, doesn't seem to work.
use Doctrine\ORM\Mapping\Entity;
**
* #Entity(repositoryClass="App\Repository\MyClassRepository")
*/
class MyClass
{
works fine.
use Doctrine\ORM\Mapping\Entity;
#[Entity(repositoryClass: MyClassRepository::class)]
class MyClass
{
Return [critical] Uncaught PHP Exception Doctrine\ORM\Mapping\MappingException: "Class "App\Entity\MyClass" is not a valid entity or mapped super class." at .../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php line 378
here is my composer.json :
"composer/package-versions-deprecated": "1.11.99.1",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "^3.0",
"symfony/console": "5.2.*",
"symfony/dotenv": "5.2.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.2.*",
"symfony/proxy-manager-bridge": "5.2.*",
"symfony/yaml": "5.2.*"
This is because of doctrine bundle configuration. If all entities within the bundle use attributes just switch the metadata driver from "annotation" to "attribute"
doctrine:
orm:
auto_generate_proxy_classes: true
entity_managers:
default:
...
mappings:
MyBundle:
type: attribute
If some entities within a bundles use attributes and some others annotations - than it is better either choose only one format for metadata or implement a custom metadata driver.
The solution is use a custom AnnotationDriver.
Sample fully works implementation: https://github.com/baraja-core/doctrine/blob/master/src/Orm/Mapping/AnnotationDriver.php
Yesterday I updated my PHP version from 5.6 to 7.0 in a docker project using Symfony v2.8.51 where I'm now facing the issue of some of the dependencies not working.
I upgraded my packages but I am getting an error for the doctrine bundle package.
When I load the project in my browser I am getting:
Unable to load class "Doctrine\Bundle\DoctrineBundle\Registry"
in ClassCollectionLoader.php line 309
at ClassCollectionLoader::getOrderedClasses(array('Doctrine\Bundle\DoctrineBundle\Registry', 'Doctrine\Common\Annotations\DocLexer', ...
the function this error is referring to looks like this:
{
$classes = array();
foreach ($class->getInterfaces() as $interface) {
$classes = array_merge($classes, self::getInterfaces($interface));
}
if ($class->isUserDefined() && $class->isInterface() && !isset(self::$seen[$class->getName()])) {
self::$seen[$class->getName()] = true;
$classes[] = $class;
}
return $classes;
}
My composer json requirements look like this:
"php": ">=7.0",
"symfony/symfony": "^2.6.4",
"doctrine/orm": "^2.5.0",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "#stable",
"symfony/swiftmailer-bundle": "#stable",
"symfony/monolog-bundle": "3.0",
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
"friendsofsymfony/jsrouting-bundle": "2.0.0",
"jms/serializer-bundle": "#stable",
"liuggio/excelbundle": "~2.0",
"ircmaxell/password-compat": "~1.0.3",
"stof/doctrine-extensions-bundle": "~1.1#dev",
"symfony/console": "^2.5.6",
"imagine/imagine": "#stable",
"liip/imagine-bundle": "#stable",
"soundasleep/html2text": "^0.5.0",
"snc/redis-bundle": "1.1.10",
"predis/predis": "^1.0",
"stackify/monolog": "~1.0",
"lexik/maintenance-bundle": "^2.1"
},
I’m not sure what exactly I need to do to get it to work again or what would be the best approach to upgrade all of my dependencies correctly since I don't have a lot of experience with it.
I have a new error after upgrading, that should not be related to the upgrade.
I am using SendInBlue Php Library in my project, loaded in my composer with :
"sendinblue/api-v3-sdk": "*#dev",
Used in my Service with:
use SendinBlue\Client\Api\SMTPApi;
use SendinBlue\Client\Model\SendEmail;
Called with :
$api_instance = new SMTPApi();
Since the upgrade I have a new error:
Attempted to load class "SMTPApi" from namespace "SendinBlue\Client\Api".
Did you forget a "use" statement for another namespace?
I tried clear cache, have rm -rf remove cache, Invalidate my phpStorm Cache + Restart, remove the two USE statement, and then look what is displayed when I try to create a new instance, but it's still the same USE statement that is added.
If I COMMAND+CLICK on the class called, it does show the related class (SMTPApi).
I am totally lost on what could be the problem here, is it symfony upgrade related ? Is it composer update that changed other things ?
for more information, here is the header of my Service:
namespace App\Services;
use FOS\UserBundle\Mailer\MailerInterface;
use FOS\UserBundle\Model\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\Router;
use SendinBlue\Client\Api\SMTPApi;
use SendinBlue\Client\Model\SendEmail;
And here is my composer:
{ [...]
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.69",
"beelab/tag-bundle": "^1.4.0",
"friendsofsymfony/user-bundle": "^2.1",
"google/apiclient": "^2.0",
"gumlet/php-image-resize": "^1.9",
"kunalvarma05/dropbox-php-sdk": "^0.2.1",
"lildude/phpsmug": "^4.0",
"sendinblue/api-v3-sdk": "*#dev",
"sensio/framework-extra-bundle": "^5.1",
"sensiolabs/security-checker": "^4.1",
"symfony/apache-pack": "^1.0",
"symfony/asset": "^4.2",
"symfony/console": "^4.2",
"symfony/debug-pack": "^1.0",
"symfony/dependency-injection": "^4.2",
"symfony/dotenv": "^4.2",
"symfony/flex": "^1.0",
"symfony/form": "^4.2",
"symfony/framework-bundle": "^4.2",
"symfony/lock": "^4.2",
"symfony/maker-bundle": "^1.4",
"symfony/monolog-bundle": "^3.3",
"symfony/orm-pack": "^1.0",
"symfony/swiftmailer-bundle": "^3.0",
"symfony/translation": "^4.2",
"symfony/twig-bundle": "4.2",
"symfony/web-server-bundle": "^4.2",
"symfony/yaml": "^4.2"
},
"require-dev": {
"easycorp/easy-log-handler": "^1.0.2",
"symfony/debug-bundle": "^3.3|^4.2",
"symfony/profiler-pack": "^1.0",
"symfony/var-dumper": "^3.3|^4.2"
},
[...]
}
As said up here, needed to revert the library. Maybe now it's fixed by the creator on GIT.
It's actually the first time for very long that I haven't found a single search result for an error message. On every page load I get a popup message saying:
"An error occurred while loading the web debug toolbar (500: Internal Server Error).
Do you want to open the profiler?" And when I open the profiler / logs:
Variable "app" does not exist in #Doctrine/Collector/db.html.twig at line 1
I made some translations and edits of twig templates - really nothing fancy. Now the profiler fails to load on every page.
my composer.json:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.6.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.4.*",
"twig/extensions": "1.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"incenteev/composer-parameter-handler": "~2.0",
"stof/doctrine-extensions-bundle": "~1.1#dev",
"friendsofsymfony/user-bundle": "1.3.*#dev",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"doctrine/migrations": "1.0.*#dev",
"doctrine/doctrine-migrations-bundle": "~1.0"
},
caches cleared, etc. I'm not asking for a solution but do you have any clue what the case could be here?
Thank you very much for your help & time!
Moritz
It may still be related to the cache, try to rebuild your bootstrap cache in addition to cache:clear prod & dev.
php ./vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
PS: the path may be different in your symfony version.
This is a weird one. After running a $ composer update on my project, I'm suddenly getting
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "assetic.read_from".
errors. Checking the Symfony 2 docs, assetic.read_from is still a valid configuration setting. My current config.yml has:
assetic:
read_from: "%kernel.root_dir%/../../www/www"
write_to: "%assetic.read_from%"
Manually deleting the cache doesn't help it. I can comment out those two lines, which removes the thrown exception, but that doesn't really address the underlying issue.
Were read_from and write_to stealth removed/deprecated? Or is something else going on?
EDIT: my composer.json is:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"twig/extensions": "~1.0",
"symfony/assetic-bundle": "2.6.*",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~3.0",
"sensio/framework-extra-bundle": "~3.0",
"incenteev/composer-parameter-handler": "~2.0",
"jms/security-extra-bundle": "dev-master",
"jms/di-extra-bundle": "dev-master",
"friendsofsymfony/user-bundle": "2.0.*#dev",
"roave/security-advisories": "dev-master"
}